CIW
1D0-635 · Question #47
You want to add a personalized interaction with your users when they enter your Web site. To do this, you can display a JavaScript prompt on the home page that asks the user to enter her name. When…
The correct answer is A. alert("Welcome, " + prompt("What is your name?", "")). See the full explanation below for the reasoning.
Question
You want to add a personalized interaction with your users when they enter your Web site. To do this, you can display a JavaScript prompt on the home page that asks the user to enter her name. When the user enters text and clicks the OK button, an alert dialog box will appear and display the text "Welcome, name" (where name is the text entered by the user). Which choice shows the correct JavaScript code for this action?
Options
- Aalert("Welcome, " + prompt("What is your name?", ""));
- Balert("Welcome, ") + prompt("What is your name?", "");
- Cprompt("What is your name?", "") + alert("Welcome, ");
- Dprompt("What is your name?", "" + alert("Welcome, "));
How the community answered
(24 responses)- A79% (19)
- B4% (1)
- C4% (1)
- D13% (3)
Community Discussion
No community discussion yet for this question.