Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day May 2, 2025

  1. Incorrect Correct No Answer was selected Invalid 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!");
        } else if (guess < randomNumber) {
            console.log("Sorry, your guess is too low. Try again.");
        } else {
            console.log("Sorry, your guess is too high. Try again.");
      }
    }
    JavaScript

    Which of the options below will fix the program?