FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 13   



Following program shows you how to take a number as input and tells its even or odd number.
This program divides input by 2, If remainder is zero it prints even otherwise it prints odd

var i = prompt("Please enter a number:");
if (i % 2 == 0) {
console.log("even");
} else {
console.log("odd")
}

Output:

Example1:

Please enter a number:
4
even

Example2:

Please enter a number:
-5
odd



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News