Files
30-seconds-of-code/snippets/isOdd.md
Davis Raimon 2291cfe884 Checking whether a number is Odd.
Using modulo function to determine whether the number is odd.
2019-09-25 23:05:06 +05:30

321 B

title, tags
title tags
isOdd math,beginner

Returns true if the given number is odd, false otherwise.

Checks whether a number is odd or even using the modulo (%) operator. Returns true if the number is odd, false if the number is even.

const isOdd = num => num % 2 === 1;
isOdd(3); // true