Files
30-seconds-of-code/javascript/snippets/is-odd.md
2023-05-01 22:35:56 +03:00

376 B

title, type, tags, cover, dateModified
title type tags cover dateModified
Number is odd snippet
math
flower-portrait-5 2020-10-20T23:02:01+03:00

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