document.querySelector() not working

I’m wanting to log the input of a number field. But I keep getting an error that value is null. Why?:
<input type="number" id="your-guess" />
let inputNum = Number(document.querySelector("#your-guess").value); console.log(inputNum)

What do you see in the browser console, if you add the following before your let inputNum... line.


console.log(document.querySelector("#your-guess")); let inputNum = Number(document.querySelector("#your-guess").value);
Typing this code above into the console gives me the error message
Identifier 'inputNum' has already been declared

That tells you that somewhere above the let inputNum line, you have already declared inputNum. Without seeing your entire code, I can not tell you exactly where you declared it the first time.