Nocturnal Programmer's Machine

    num-is-even-or-odd

    1.0.6 • 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 --save num-is-even-or-odd

    Usage

    Works with strings or numbers.

    You can pass an 'str' or 'bool' parameter to return the result in string or boolean, by defualt the function will return in string format.

    const evenOrOdd = require('num-is-even-or-odd');
    
    // Whitout any return type parameter
    
    console.log(evenOrOdd(1)); //=> "odd"
    console.log(evenOrOdd(2)); //=> "even"
    
    console.log(evenOrOdd('1')); //=> "odd"
    console.log(evenOrOdd('2')); //=> "even"
    
    // With 'str' parameter
    
    console.log(evenOrOdd(1, 'str')); //=> "odd"
    console.log(evenOrOdd(2, 'str')); //=> "even"
    
    console.log(evenOrOdd('1', 'str')); //=> "odd"
    console.log(evenOrOdd('2', 'str')); //=> "even"
    
    // With 'bool' parameter
    
    console.log(evenOrOdd(1, 'bool')); //=> 1
    console.log(evenOrOdd(2, 'bool')); //=> 0
    
    console.log(evenOrOdd('1', 'bool')); //=> 1
    console.log(evenOrOdd('2', 'bool')); //=> 0

    Author

    Otavio Rampinelli

    License

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


    Install

    npm i num-is-even-or-odd

    DownloadsWeekly Downloads

    11

    Version

    1.0.6

    License

    MIT

    Unpacked Size

    4.62 kB

    Total Files

    5

    Last publish

    Collaborators

    • otarampinelli