Get Programming with JavaScript - Listing 5.08

Listing 5.08 - Displaying a player's name via an object property

var player1; var player2; var showPlayerName; showPlayerName = function (playerName) { console.log(playerName); }; player1 = { name: "Kandra", place: "The Dungeon of Doom", health: 50 }; player2 = { name: "Dax", place: "The Old Library", health: 40 }; showPlayerName(player1.name); showPlayerName(player2.name);

Further Adventures

Listing 5.08 - Displaying a player's name via an object property - Task 1

var player1; var player2; var showPlayerName; showPlayerName = function (playerName) { console.log(playerName.toUpperCase()); }; player1 = { name: "Kandra", place: "The Dungeon of Doom", health: 50 }; player2 = { name: "Dax", place: "The Old Library", health: 40 }; showPlayerName(player1.name); showPlayerName(player2.name);

Listing 5.08 - Displaying a player's name via an object property - Task 2

var player1; var player2; var showPlayerName; showPlayerName = function (playerName) { console.log(playerName.toLowerCase()); }; player1 = { name: "Kandra", place: "The Dungeon of Doom", health: 50 }; player2 = { name: "Dax", place: "The Old Library", health: 40 }; showPlayerName(player1.name); showPlayerName(player2.name);