'F' → Fullscreen
console.log("--- Demo 1: Traverse Cities ---");
let cities = ["Cleveland", "Chicago", "New York", "Dallas", "Seattle"];
// Use a while loop to print every city in this format:// 0: Cleveland// 1: Chicago// ...let i = 0;while (i < cities.length) { console.log(i + ": " + cities[i]); i++;}
// (Quick Check): What would happen if you changed the loop condition to:// while (i <= cities.length) ?// Answer as a comment below.
prompt("Press enter to continue...");// -----------------------------------------------------------------------------22 collapsed lines
console.log("--- Demo 1: Traverse Cities ---");
let cities = ["Cleveland", "Chicago", "New York", "Dallas", "Seattle"];
// Use a while loop to print every city in this format:// 0: Cleveland// 1: Chicago// ...let i = 0;while (i < cities.length) { console.log(i + ": " + cities[i]); i++;}
// (Quick Check): What would happen if you changed the loop condition to:// while (i <= cities.length) ?// Answer as a comment below.
prompt("Press enter to continue...");// -----------------------------------------------------------------------------
console.log("--- Demo 2: Simple Task App ---");
let tasks = [];let choice = "";
while (choice != "3") { console.log("- Main Menu -"); console.log("1) Add task"); console.log("2) List tasks"); console.log("3) Exit"); choice = prompt("->");
if (choice == "1") { let newTask = prompt("Enter task:"); tasks.push(newTask); console.log(newTask + " added to tasks.\n"); } else if (choice == "2") { console.log("--Tasks--");
if (tasks.length == 0) { console.log("No tasks to complete."); }
let i = 0; while (i < tasks.length) { console.log("* " + tasks[i]); i++; }
console.log(); // Add spacing after list } else if (choice == "3") { console.log("Exiting app.\n") } else { console.log("Invalid option - Please try again.\n"); }}Your program output should something similar to the sample output below.
--- Demo 1: Traverse Cities ---0: Cleveland1: Chicago2: New York3: Dallas4: SeattlePress enter to continue... [Enter]
--- Demo 2: Simple Task App ---- Main Menu -1) Add task2) List tasks3) Exit-> 1Enter task: Practice arraysPractice arrays added to tasks.
- Main Menu -1) Add task2) List tasks3) Exit-> 1Enter task: Pack gym clothesPack gym clothes added to tasks.
- Main Menu -1) Add task2) List tasks3) Exit-> 2--Tasks--* Practice arrays* Pack gym clothes
- Main Menu -1) Add task2) List tasks3) Exit-> 3Exiting app.You may write your reflection answers as comments at the bottom of your code.
Submit your activity and reflection answers to the appropriate dropbox.