'F' → Fullscreen
console.log("--- Demo 1: Trivia Game ---");
// Trivia questions and answerslet questions = [ "What planet is known as the Red Planet?", "How many bits are in a byte?", "What language are we programming in?"];
let answers = [ "mars", "8", "javascript"];
// Score trackerlet score = 0;let i = 0;
// Ask each questionwhile (i < questions.length) { let response = prompt(questions[i]).toLowerCase();
if (response == answers[i]) { console.log("Correct!"); score++; } else { console.log("Incorrect. The correct answer was: " + answers[i]); }
i++;}
// Final resultconsole.log("You answered " + score + " out of " + questions.length + " correctly.");
prompt("Press enter to continue...");console.log("--- Demo 2: Trivia Game Summary ---");
// Example score datalet scores = [2, 3, 1, 3, 2];
// Calculate class average scorelet total = 0;let i = 0;
while (i < scores.length) { total += scores[i]; i++;}
let average = total / scores.length;
console.log("Average trivia score:", average);
if (average == scores.length) { console.log("Perfect average! Everyone nailed it!");} else if (average >= 2) { console.log("Nice job overall!");} else { console.log("Looks like we need more practice!");}
prompt("Press enter to continue...");--- Demo 1: Trivia Game ---What planet is known as the Red Planet? marsCorrect!How many bits are in a byte? 8Correct!What language are we programming in? javascriptCorrect!You answered 3 out of 3 correctly.Press enter to continue... [Enter]
--- Demo 2: Trivia Game Summary ---Average trivia score: 2.2Nice job overall!Press enter to continue... [Enter]You may write your reflection answers as comments at the bottom of your code.
Submit your activity and reflection answers to the appropriate dropbox.