🚀 30 Days of JavaScript – Day 12 Can you solve these number puzzles? 🤔 Today I built a small JavaScript program that asks 3 number pattern questions and calculates the final score. 🧠 Concepts Used: conditional statements user input with prompt() variables and score tracking 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #CodingChallenge #ProblemSolving #LearningJavaScript #WebDevelopment

let score = 0; //Q1 let q1 = prompt("Guess the next number:\n2, 4, 8, 16, ?"); if (Number(q1) === 32) {   alert("Correct!");   score++; } else {   alert("Wrong! Correct answer is 32"); } // Q2 let q2 = prompt("Guess the next number:\n3, 6, 9, 12, ?"); if (Number(q2) === 15) {   alert("Correct!");   score++; } else {   alert("Wrong! Correct answer is 15"); } // Q3 let q3 = prompt("Guess the next number:\n5, 10, 20, 40, ?"); if (Number(q3) === 80) {   alert("Correct!");   score++; } else {   alert("Wrong! Correct answer is 80"); } alert("Your score: " + score + " / 3"); let playAgain = confirm("Play again?"); if (playAgain) {   location.reload(); } else {   alert("Thanks for playing!"); }

Like
Reply

To view or add a comment, sign in

Explore content categories