NPM Smell 🍑💨

trivial and outdated NPM packages

is-odd trivial npm logo

Checks if a number is odd.

Weekly Downloads
259,753
Dependencies
1
Latest Release
8 years ago
Better as a utility function
Trivial

Dependency Tree

  • is-odd @3.0.1 (1)
    • is-number @6.0.0

About

This dependency checks if a number is odd.

This can be done natively with the % remainder operator. It returns the remainder leftover.

1 % 2; // 1
2 % 2; // 0
3 % 2; // 1
4 % 2; // 0
// ...

Odd numbers return 1, so a corresponding function would look like:

function isOdd(number) {
    return number % 2 !== 0;
}

isOdd(3); // true
isOdd(6); // false