Assignment 012

JavaScript Methods - Variables

Variables are temporary holding areas for information you want to store. For example, in your math classes you have assigned numbers to a variables like so:

x=5

y=4

Therefore, x + y = 9

The JavaScript prompts on this page are doing the same. They are requesting two numbers from the user and assigning the values to two variables. The numbers you entered, in response to the prompts, are stored in variables named 'firstnumber' and 'secondnumber.'

Once variables are stored, they can be manipulated. In this case, 'firstnumber' and 'secondnumber' are multiplied to determine their product. Let's say you entered 5 at the first prompt and 6 at the second prompt. This is what happened:

firstnumber = 5 (The first number variable was set to 5)

secondnumber = 6 (The second number variable was set to 6)

firstnumber * secondnumber = 30 (the variables were multiplied to determine their product)

We used JavaScript to write the result on this Web page.