Find Even or Odd in JavaScript

A simple java script snippet to find a number is even or odd

Source code :

var n = prompt("Enter a number to find odd or even");
 if (n === 0)
{
alert("The number is zero");
}
else if (n%2)
{
alert("The number is odd");
}
else
{
alert("The number is even");
}

Output :

The number is even

Output :


                

Comments :