# JavaScript Program to Find whether a Number is Even or Odd with Source Code

Use modulus (%). It gives you the remainder of the two numbers you are dividing.
Here in our Program, if you mod any number x by 2, you get either 0 or 1 or -1. 0 would mean it's even. Anything else would mean it's odd. This is the simple funda.

<!DOCTYPE html>
<html>
<title></title>

<body>

<h2 style="text-align: center; color: white; background-color: #FA2B6D"> JavaScript to find Odd or Even number! </h2>

<label> Enter Number </label> <br>
<input type="number" name="" id="evenOdd" onkeyup="isCheck()">
<span id="showMssg" style="color: #342BFA;">  </span>
</br><br>

<label> Enter Number </label> <br>
<input type="number" name="" id="evenOdds" onkeyup="isChecks()">
<span id="showMssgs" style="color: #FA2B44;">  </span>

<script>

function isCheck(){
var num = document.getElementById('evenOdd').value;
if((num%2) == 0){
document.getElementById('showMssg').innerHTML = "Hurray! Number "+num+"  is an even number";
}
else{
document.getElementById('showMssg').innerHTML = "Oo No! "+num+"  is not an even number";
}

if(num === ""){
document.getElementById('showMssg').innerHTML = "";
}
}

function isChecks(){
var num = document.getElementById('evenOdds').value;
if((num%2) == 0){
document.getElementById('showMssgs').innerHTML = "Hurray! Number "+num+"  is an even number";
}
else{
document.getElementById('showMssgs').innerHTML = "Oo No! "+num+"  is not an even number";
}

if(num === ""){
document.getElementById('showMssgs').innerHTML = "";
}
}

</script>

</body>
</html>