So I'm trying to take an element submitted into an input field and return a result using if else statements but it keeps returning my "else" statement no matter what. I used a w3schools project to begin with, but I can't seem to see what is going wrong.
The user will put a number is the "numSpots" input field and depending on the value of the number, an adaSpots value will get returned in the paragraph id="demo"
Here is my code
function myFunction() {
var numSpots = document.getElementById("numSpots");
var adaSpots;
if (numSpots < 25) {
adaSpots = "1";
} else {
adaSpots = "267";
}
document.getElementById("demo").innerHTML = adaSpots;
}
<p>Click the button to display a time-based greeting:</p>
<input type="number" name="numSpots" id="numSpots" />
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>