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?
A.
alert(“Welcome, ” + prompt(“What is your name?”, “”));
B.
alert(“Welcome, “) + prompt(“What is your name?”, “”);
C.
prompt(“What is your name?”, “”) + alert(“Welcome, “);
D.
prompt(“What is your name?”, “” + alert(“Welcome, “));
Explanation:
Answer is C
ILucky: No, the answer is not C. The above is correct as A. Test them out in a browser to see for yourself.
A is the correct answer