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:
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
The data that the prompt actually obtains is a string So both firstNumber and secondNumber contain t... View full answer
Get step-by-step solutions from verified subject matter experts
