[Solved] How to check if number is even in Javascript?

  

3
Topic starter

I need to write a script to check if particular number is even in Javascript (with true or false booleans).

1 Answer
2

Here's one simple solution:

function isEven(num) {
    return num % 2 === 0;
}

and a short video with embedded javascript in html:

another one:

function isEven(num) {
    if (num % 2 === 0) {
        return true;
    } else {
        return false;
    }
}
Share: