Even or Odd using JavaScript

USING INPUT BOX

<html>
Number:
<input type="number" id="number">
<br><br>
Result:
<input id="result" disabled>
<br><br>
<button onclick="checkEvenOdd()">Check Even/Odd</button>
<script>
function checkEvenOdd()
{
let number = parseInt(document.getElementById("number").value);
if (number % 2 === 0)
{
document.getElementById("result").value = "Even";
}
else
{
document.getElementById("result").value = "Odd";
}
}
</script>
</html>

 

___________________________________________________________________________________________________________________________

 

USING PROMPT

<script>
function evenOrOdd(number)
{
if (number % 2 == 0)
{
alert ("Even");
} else
{
alert ("Odd");
}
}
let number = prompt("Enter a number:");
let result = evenOrOdd(number);
</script>