@dev-manager/odd-even
v1.0.1
Published
A simple npm package to check if a number is odd or even
Downloads
25
Readme
@dev-manager/odd-even
A simple and lightweight npm package to check whether a number is odd or even.
📦 Installation
Install the package using npm:
npm install @dev-manager/odd-evenOr with yarn:
yarn add @dev-manager/odd-even🚀 Usage
Import the functions and use them in your project:
CommonJS (Node.js)
const { isOdd, isEven } = require("@dev-manager/odd-even");
console.log(isOdd(5)); // true
console.log(isEven(10)); // true🧠 API Reference
isOdd(number)
Checks whether the given number is odd.
Parameters
number(Number) – The number to check
Returns
trueif the number is oddfalseif the number is even
Example
isOdd(7); // true
isOdd(4); // falseisEven(number)
Checks whether the given number is even.
Parameters
number(Number) – The number to check
Returns
trueif the number is evenfalseif the number is odd
Example
isEven(8); // true
isEven(3); // false⚠️ Error Handling
Both functions throw a TypeError if the input is not a number.
isOdd("5");
// Throws: TypeError: Input must be a number🧪 Example
const { isOdd, isEven } = require("@dev-manager/odd-even");
const num = 12;
if (isEven(num)) {
console.log(`${num} is even`);
} else {
console.log(`${num} is odd`);
}📄 License
This project is licensed under the MIT License.
👤 Author
Kuldeep Chouhan
🤝 Contributing
Contributions, issues, and feature requests are welcome!
Feel free to open a pull request or raise an issue.
⭐ Support
If you find this package helpful, consider giving it a star 🙂
