PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

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:

PrepAway - Latest Free Exam Questions & Answers

3 Comments on “Which choice shows the correct JavaScript code for this action?


Leave a Reply