aadii-isodd
v1.0.0
Published
"check number is odd or not"
Readme
is-odd
A simple Node.js utility to check whether a number is odd.
Installation
Install the package via npm:
npm install is-oddUsage
Import the package and use the isOdd function to check if a number is odd:
const isOdd = require('is-odd');
console.log(isOdd(3)); // true
console.log(isOdd(4)); // false
console.log(isOdd(0)); // false
console.log(isOdd(-5)); // trueHow It Works
The isOdd function determines whether a number is odd by checking if it is not divisible by 2:
function isOdd(n) {
return n % 2 !== 0;
}- Odd Numbers: Return
true. - Even Numbers: Return
false. - Zero: Return
false. - Negative Numbers: Return
truefor odd negatives,falsefor even negatives.
Examples
| Input | Output |
|--------|--------|
| 3 | true |
| 4 | false|
| 0 | false|
| -5 | true |
| -6 | false|
Key Features
- Lightweight: No dependencies.
- Cross-Environment: Works in Node.js and browser environments.
- Simple Logic: Handles both positive and negative numbers seamlessly.
License
This project is licensed under the MIT License.
Feel free to contribute or report issues on GitHub.
