showIntro(), displayMenu(), and gameOver(). function showIntro() { console.log("--- MINI GAME COLLECTION VOL. 1 ---"); console.log("Welcome!"); console.log();}
function displayMenu() { console.log("1. Guess the Number"); console.log("2. Lucky Dice"); console.log("3. Spin the Wheel"); console.log("4. Exit"); console.log();}
function gameOver() { console.log("Thanks for playing!"); console.log("Goodbye!");}
// Call your functions here:showIntro();displayMenu();// Later, you'll decide where to call gameOver()while loop and
if / else if / else statements. The mini-game functions will be implemented in the next
task. function showIntro() {3 collapsed lines
console.log("-- MINI GAME COLLECTION VOL. 1 --"); console.log("Welcome!"); console.log();}
function displayMenu() {5 collapsed lines
console.log("1. Guess the Number"); console.log("2. Lucky Dice"); console.log("3. Spin the Wheel"); console.log("4. Exit"); console.log();}
function gameOver() {2 collapsed lines
console.log("Thanks for playing!"); console.log("Goodbye!");}
function playGuessTheNumber() { // To Do: Guess the Number Mini-Game}
function playLuckyDice() { // To Do: Lucky Dice Mini-Game}
function playSpinTheWheel() { // To Do: Spin the Wheel Mini-Game}
let choice = "";
showIntro();
while (choice !== "4") { displayMenu(); choice = prompt("Choose mini-game: ");
if (choice == "1") { playGuessTheNumber(); } else if (choice == "2") { playLuckyDice(); } else if (choice == "3") { playSpinTheWheel(); } else if (choice == "4") { gameOver(); } else { console.log("Invalid choice."); }
console.log();}function showIntro() {3 collapsed lines
console.log("-- MINI GAME COLLECTION VOL. 1 --"); console.log("Welcome!"); console.log();}
function displayMenu() {5 collapsed lines
console.log("1. Guess the Number"); console.log("2. Lucky Dice"); console.log("3. Spin the Wheel"); console.log("4. Exit"); console.log();}
function gameOver() {2 collapsed lines
console.log("Thanks for playing!"); console.log("Goodbye!");}
function playGuessTheNumber() { console.log("--- Guess the Number ---");
let secret = Math.floor(Math.random() * 10) + 1; let guessText = prompt("Guess my secret number between 1 and 10: "); let guess = Number(guessText);
console.log("It was " + secret + "!");
if (guess == secret) console.log("You Win!"); else console.log("You Lose!");}
function playLuckyDice() { console.log("--- Lucky Dice ---"); console.log();
let betText = prompt("Bet on a total between 2 and 12: "); let bet = Number(betText);
let die1 = Math.floor(Math.random() * 6) + 1; let die2 = Math.floor(Math.random() * 6) + 1; let total = die1 + die2;
console.log("You rolled " + die1 + " and " + die2 + " (total: " + total + ").");
if (total == bet) console.log("You Win!"); else console.log("You Lose!");}
function playSpinTheWheel() { console.log("--- Spin the Wheel ---"); console.log();
let betText = prompt("Pick a number on the wheel between 1 and 25: "); let bet = Number(betText);
let wheel = Math.floor(Math.random() * 25) + 1;
console.log("The wheel landed on " + wheel + ".");
if (wheel == bet) console.log("You Win!"); else console.log("You Lose!");}
26 collapsed lines
let choice = "";
showIntro();
while (choice !== "4") { displayMenu(); choice = prompt("Choose mini-game: ");
if (choice == "1") { playGuessTheNumber(); } else if (choice == "2") { playLuckyDice(); } else if (choice == "3") { playSpinTheWheel(); } else if (choice == "4") { gameOver(); } else { console.log("Invalid choice."); }
console.log();}Your program output should look similar to the sample output below.
-- MINI GAME COLLECTION VOL. 1 --Welcome!
1. Guess the Number2. Lucky Dice3. Spin the Wheel4. Exit
Choose mini-game: 1--- Guess the Number ---Guess my secret number betwen 1 and 10: 7It was 7!You Win!
1. Guess the Number2. Lucky Dice3. Spin the Wheel4. Exit
Choose mini-game: 4Thanks for playing!Goodbye!You may write your reflection answers as comments at the bottom of your code.
Submit your completed .js file and reflection answers to the
appropriate dropbox.