It checks if the number is bigger or smaller or not and also if the user has quit by entering "q". But it doesn't catch invalid input like "&, *, (, p, ]" with "while(!guess)".
let guess = window.prompt('guess the number!');
const rand = Math.floor(Math.random() * 10) + 1;
let tries = 0;
while (!guess) {
let guess = parseInt(prompt('enter a valid number'));
}
while (parseInt(guess) !== rand) {
tries += 1;
if (guess === 'q') {
console.log('you have exited');
break;
}
if (guess < rand) guess = prompt('enter higher!');
else guess > rand;
guess = prompt('enter lower!');
}
console.log(`correct number is : ${rand} and it took you ${tries} tries`);