Number is odd

OSCC · JavaScript, Math · Oct 20, 2020

Checks if the given number is odd.

  • Check whether a number is odd or even using the modulo (%) operator.
  • Return true if the number is odd, false if the number is even.
const isOdd = num => num % 2 === 1;
isOdd(3); // true

Would you like to help us improve 30 seconds of code?Take a quick survey

Recommended snippets

  • Validate number

    JavaScript, Math

    Checks if the given value is a number.

  • Number in range

    JavaScript, Math

    Checks if the given number falls within the given range.

  • Number is even

    JavaScript, Math

    Checks if the given number is even.