isEven

JavaScript, Math

Checks if the given number is even.

  • Checks whether a number is odd or even using the modulo (%) operator.
  • Returns true if the number is even, false if the number is odd.
const isEven = num => num % 2 === 0;
isEven(3); // false

Recommended snippets

  • validateNumber

    JavaScript, Math

    Checks if the given value is a number.

  • inRange

    JavaScript, Math

    Checks if the given number falls within the given range.

  • isOdd

    JavaScript, Math

    Checks if the given number is odd.