JavaScript program to guess a random number:
let randomNumber = Math.floor(Math.random() * 100) + 1;
let guessedNumber = parseInt(prompt("Guess the number between 1 and 100:"));
while (guessedNumber !== randomNumber) {
if (guessedNumber < randomNumber) {
alert("Too low. Guess again.");
} else {
alert("Too high. Guess again.");
}
guessedNumber = parseInt(prompt("Guess the number between 1 and 100:"));
}
alert("You guessed it right. The number was " + randomNumber);