num-is-even-or-odd
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

num-is-even-or-odd NPM version NPM monthly downloads NPM total downloads

Return even or odd to as result to a given number.

Install

Install with npm:

$ npm install -D num-is-even-or-odd

Usage

import { evenOrOdd } from 'num-is-even-or-odd'

const { isEvenOrOdd, isEven, isOdd } = evenOrOdd()

// Method to verify even and odd

console.log(isEvenOrOdd(3)); //=> "odd"
console.log(isEvenOrOdd(4)); //=> "even"

// You can pass a "returnAsBool" boolean parameter to return results as boolean, true to even and false to odd, default value for parameter is false

console.log(isEvenOrOdd(3, true)); //=> false (odd)
console.log(isEvenOrOdd(4, true)); //=> true (even)

// Method to verify if the value is odd

console.log(isOdd(3)); //=> true
console.log(isOdd(4)); //=> false

// Method to verify if the value is even

console.log(isEven(3)); //=> false
console.log(isEven(4)); //=> true

Author

Otavio Rampinelli

License

Copyright © 2023, Otavio Rampinelli. Released under the MIT License.


Package Sidebar

Install

npm i num-is-even-or-odd

Weekly Downloads

15

Version

2.0.2

License

MIT

Unpacked Size

7.49 kB

Total Files

8

Last publish

Collaborators

  • otarampinelli