I want a function in JavaScript. It should accept a user number from an <input>
and then it should check if the user number is 21
. If it is, alert "T"
; if it was another number, alert "F"
. The function should trigger when the <input>
has been clicked.
var userNum = document.getElementById("number-input");
function num(userNum) {
if (userNum === 21) {
window.alert("T");
}
else {
window.alert("F");
}
}
<input onclick="num();" value="Check" type="submit" style="border-radius: 10px;" class="btn btn-dark mb-1" />