JavaScript – How to check number is odd or even

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");
]

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

DMCA.com Protection Status