JavaScript in 60 Seconds

Variables

It can often be useful to to assign a value to a variable.

Like in a math formula: x = a + 5

Var keyword

In JavaScript we can store a value in a variable with the var keyword.

var x = 5; x;

You can reassign the value later.

var x = 5; x = 6; x = 7; x;

You can see the result below the code.

Now you try it. Make some changes to the code.

5+5

results in the same as

var x = 5; x + x; //5+5

Try changing the code above.

Nice job! On to the next lesson.