Angie I.

asked • 07/08/21

I am currently struggling with why not all the curly brackets are closed as shown below

let correctGuess = false;
const number = 6;
const guess = prompt('Guess a number between 1 and 10.');

if ( +guess === number ) {
correctGuess = true;
} else if ( +guess < number ) {
const guessMore = prompt(`Try again. The number is higher than ${guess}`);
if ( +guessMore === number ) {
correctGuess = true;
}
} else if ( +guess > number ) {
const guessLess = prompt(`Try again. The number is lower than ${guess}`);
if ( +guessLess === number ) {
correctGuess = true;
}
}

if ( correctGuess ) {
console.log("You guessed the number!");
} else {
console.log(`Sorry. The number was ${number}.`);
}


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.