Я начинающий программист JavaScript. Я сделал очень простую игру на JavaScript по угадыванию чисел от 1 до 10. Но она не работает. Может ли кто-нибудь взглянуть на этот код и сказать мне, что в нем не так?
// getting the value of a textbox
let guess=document.getElementById('text').value;
let GuessNumber=3;
// creating a function to check whether the userinput and the variable is same on the click of a button.
document.getElementById("submit").onclick=()=>{
// if the user input and the number is same just display gift
if(guess==GuessNumber){
document.getElementById("P").innerHTML="Gift";
}
// if the user input is not a number display 'it should be a number'
else if(isNaN(guess)){
document.getElementById("P").innerHTML="It should be a number";
}
// if the user input is a number greater than 10 or less than 1 display 'it is a number between 1 and 10.
else if(guess>11||guess
Подробнее здесь: https://stackoverflow.com/questions/719 ... javascript