Question: The following code uses the prompt() function to get two numbers from the user. It then adds those two numbers and writes the result to

The following code uses the prompt() function to get two numbers from the user. It then adds those two numbers and writes the result to the page:Chapter 2, Question 2 var firstNumber = prompt("Enter the first number",""); var

However, if you try out the code, you’ll discover that it doesn’t work. Why not? Change the code so that it does work.

Chapter 2, Question 2 var firstNumber = prompt("Enter the first number",""); var secondNumber = prompt("Enter the second number",""); var theTotal = firstNumber + secondNumber; document.write(firstNumber + " added to " + secondNumber + equals " + the Total);

Step by Step Solution

3.38 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The data that the prompt actually obtains is a string So both firstNumber and secondNumber contain t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Beginning JavaScript Questions!