It's a small game of guess number but why the parameter in javascript ii is NaN when i run the code below in google chorme? ii should be already a int type because i use the parseInt method
Snippet
//get a int number 1~100
let num = parseInt(Math.random() * 100) + 1;
let i = document.querySelector("input");
let sp = document.querySelector("span");
//get the input and span object
let ii = parseInt(i.value);
console.log(num);
let count = 0;
function send() {
debugger
count++;
if (ii == num) {
sp.innerText = "right" + count;
} else if (ii > num) {
sp.innerText = "too big";
} else {
sp.innerText = "too small";
}
}
<input type="text" placeholder="input a int number 1~100">
<input type="button" value="guess the number" onclick="send()">
<h1>result:<span></span></h1>