Been trying to make a guessing game, I wanted to do a limit of 3 guesses but I don’t know, anyone got ideas
const minNum = 1;
const maxNum = 10;
const answer = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
let attempts = 3;
let guess;
let running = true;
while (running) {
guess = prompt(`Guess a number between ${minNum} - ${maxNum}`);
guess = Number(guess);
if (isNaN(guess)) {
prompt("This number isn't valid");
} else if (guess < minNum || guess > maxNum) {
prompt("This number isn't valid");
} else {
attempts++;
if (guess > answer) {
prompt("TOO HIGH, TRY AGAIN");
} else if (guess < answer) {
prompt("TOO LOW, TRY AGAIN");
} else {
prompt(`Correct, the number is ${answer}. it took you ${attempts} attempts!`);
running = false;
}
}
}