Even or Odd using JavaScript

Hi friends , this is code for Checking Even or Odd using JavaScript ..

Program :

<html>
<body>
<h2> EVEN or ODD </h2>
Enter a Number which you check Even or Odd :
<br></br>
<button type="button" onclick="input()">Enter a Number</button><br></br>
<button type="button" onclick="check()">check</button>
<script>
var x;
function input()
{
x = prompt("Enter a Value");
}
function check()
{
var num=parseInt(x);
if(num%2==0)
document.write("Entered Number is EVEN");
else
document.write("Entered Number is ODD");
}
</script>
</body>
</html>

Explanation :
Here x is inputted and it is typecasted into num by using parseInt and then Num is checked for even or odd by checking the remainder =0 or not , But this we can conclude our Entered Number is Even or Odd

Execute this at : http://vitaminjs.kittu.xyz/p/even-or-odd.html

Comments