Skip to content

JavaScript – How to check number is odd or even

Last updated on November 20, 2017

Here is the simple JavaScript code snippet to check if the given number is an odd or even number.

Function to check Number Is Odd Or Even

function checkEven(val){
     return (val%2 == 0);
}

How to use checkEven

val = 9;
if(checkEven(val)){
    alert("Number is even");
} else {
    alert("Number is odd");
]
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments