Get Programming with JavaScript - Listing 2.03

Listing 2.03 - Using a variable

var score; score = 100; console.log(score);

Further Adventures

To assign a value, use the assignment operator, =.

Listing 2.03 - Using a variable - Task 1

var score; score = 2500; // a new value has been assigned console.log(score);

Listing 2.03 - Using a variable - Task 2

var score; score = 2500; console.log(score); var score2; // a second variable has been declared

Listing 2.03 - Using a variable - Task 3

var score; score = 2500; console.log(score); var score2; score2 = 10; // a value has been assigned

Listing 2.03 - Using a variable - Task 4

var score; score = 2500; console.log(score); var score2; score2 = 10; console.log(score2); // the value of score2 is displayed

Video Tutorials

Declaring a variable and assigning it a value