Get Programming with JavaScript - Listing 4.08

Listing 4.08 - Displaying a menu

var displayMenu; displayMenu = function () { console.log("Please choose an option:"); console.log("(1) Print log"); console.log("(2) Upload file"); console.log("(9) Quit"); }; displayMenu();

Further Adventures

Listing 4.08 - Displaying a menu - Task 1

var displayMenu; displayMenu = function () { console.log("Please choose an option:"); console.log("(1) Print log"); console.log("(2) Upload file"); console.log("(3) Download file"); // Add more options console.log("(4) Help"); console.log("(9) Quit"); }; displayMenu();

Listing 4.08 - Displaying a menu - Tasks 2 & 3

var displayMenu; var displayMyMenu; // Declare a variable displayMenu = function () { console.log("Please choose an option:"); console.log("(1) Print log"); console.log("(2) Upload file"); console.log("(3) Download file"); console.log("(4) Help"); console.log("(9) Quit"); }; // Define a new function // Assign it to your variable displayMyMenu = function () { console.log("(1) Launch rocket"); console.log("(2) Land on Moon"); console.log("(3) Collect cheese"); console.log("(9) Quit Moon"); }; displayMenu(); displayMyMenu(); // Call your function