Get Programming with JavaScript - Listing 2.06

Listing 2.06 - Declaring and assigning in two steps

var playerName; var locationName; playerName = "Kandra"; locationName = "The Dungeon of Doom"; console.log(playerName + " is in " + locationName);

Further Adventures

Listing 2.06 - Declaring and assigning in two steps - Tasks 1, 2 and 3

var playerName; var locationName; var score; // declare a score variable playerName = "Kandra"; locationName = "The Dungeon of Doom"; score = 100; // assign it a value console.log(playerName + " is in " + locationName); // display a message on the console console.log(playerName + " has a score of " + score);