WEB-DEVELOPMENT-APPLICATIONS practice question 6 of 25
Which method allows the end user to enter text as an answer to a question as the page loads?
Choose your answer, then check it against the explanation and the full breakdown below.
Question breakdown
Key idea: window.prompt() displays a dialog with a text field and returns the text the user entered, or null if the user cancels.
How to reach the answer
- The clue is that the user must 'enter text as an answer to a question'.
- alert only displays a message.
- confirm returns true or false from the OK and Cancel buttons.
- document.write outputs content and takes no input.
- prompt is the only option that collects typed text.
Each option
Common trap: confirm is tempting because it also asks the user a question, but it only produces a yes/no boolean.
In practice: prompt is used in quick demos, learning exercises, and debugging. Production sites usually build forms or custom modals instead.
Remember: alert shows a message, confirm asks yes/no, and prompt collects text.
Drafted with AI assistance and checked against the answer key.
Keep practicing
Take the free WEB-DEVELOPMENT-APPLICATIONS practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other WEB-DEVELOPMENT-APPLICATIONS practice questions
- Question 1Given the following JavaScript code: ```javascript var n1 = 10; var n2 = "20.39"; ``` Whi…
- Question 2Which attribute displays help text in an input field without specifying an actual value f…
- Question 4Which element attaches an external CSS document to a web page?
- Question 5Which HTML tag should a developer use to create a drop-down list?
- Question 8Which layout design is easiest to manage on a variety of devices?
- Question 9Which structure tag should a developer use to place contact information on a web page?
