Which choice shows the correct JavaScript code for this action?

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?

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:



Leave a Reply 3

Your email address will not be published. Required fields are marked *


ILucky

ILucky

Answer is C

Joshua

Joshua

ILucky: No, the answer is not C. The above is correct as A. Test them out in a browser to see for yourself.

Chicco

Chicco

A is the correct answer