Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
373 B
1
Indexable
Never
var num
var randomNum
num = prompt('Enter a number: ')
randomNum = Math.floor(Math.random() * (9 + 1))

var isGuessed = false;

for(var i = 0; i<5; i++){
    if(num == randomNum){
        isGuessed = true
        alert('You guessed the number!')
        break
    }else{
        alert('Try again!')
    }
}
if(isGuessed == false){
    alert('You lost!')
}