Want to receive Question of the Day updates? Subscribe Here
JavaScript Question of the Day
May 2, 2025
IncorrectCorrectNo Answer was selectedInvalid Answer
The following program has an error in it. It’s supposed to continue prompting a user to guess a random number until they get it right, but currently, when run, nothing happens.
let randomNumber = Randomizer.nextInt(1,10);let guess =null;while(guess == randomNumber){
guess =readLine("Guess a number between 1 and 10: ");if(guess == randomNumber){
console.log("Congratulations, you guessed the correct number!");}elseif(guess < randomNumber){
console.log("Sorry, your guess is too low. Try again.");}else{
console.log("Sorry, your guess is too high. Try again.");}}