Using a variable

suggest change
var number1 = 5;
number1 = 3;

Here, number1 starts at 5 and is then changed to 3. The later snippets continue from that binding. window.alert exists in browsers. To show the value, log it or pass it to alert:

console.log(number1); // 3
window.alert(number1); // 3

To add, subtract, multiply, divide, etc., we do like so:

number1 = number1 + 5; // 3 + 5 = 8
number1 = number1 - 6; // 8 - 6 = 2
var number2 = number1 * 10; // 2 (times) 10 = 20
var number3 = number2 / number1; // 20 (divided by) 2 = 10;

We can also add strings which will concatenate them, or put them together. For example:

var myString = "I am a " + "string!"; // "I am a string!"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents