Check if a number is odd or even. If a number is odd or if the number is even it will return true.
npm install is-number-odd-or-evenis-number-odd-or-even. As it sports an incredibly fast, open-ended API, you can solve all even or odd related problems with only 1 line (sorta)
true or false, it always returns true whether the number is odd or even unless the number is neither odd nor even (which is only true if the number is infinite, or not an integer)
shell
$ npm i is-number-odd-or-even
`
$3
Just import the library and pass in two arguments: the value that you want to check is odd or even, and a boolean whether to output useful logs!
$3
Importing
`js
const isOddOrEven = require("is-number-odd-or-even")
`
Example usage:
`js
const isOddOrEven = require("is-number-odd-or-even")
const test1 = isOddOrEven(1, false) // outputs no logs because logging is disabled
const test1 = isOddOrEven(2, false) // outputs no logs because logging is disabled
const test3 = isOddOrEven(Infinity, true) // outputs logs because logging is enabled
const test4 = isOddOrEven(5.3, true) // outputs logs because logging is enabled
console.log(test1) // true
console.log(test2) // true
console.log(test3) // false (because infinity is not odd or even)
console.log(test4) // false (because decimal numbers that aren't integers are not odd or even)
``