javascript test if number is even code example
Example 1: js even or
function isEven(n) {
return n % 2 == 0;
}
function isOdd(n) {
return Math.abs(n % 2) == 1;
}
Example 2: how to check if number is even
if ( n % 2 == 0 ) {
// n is even
}
else {
//otherwise odd
}