int-to-words
is a JavaScript/Node.js package that converts numeric values into their English word representation. This utility is particularly useful for applications that need to present numbers as words, such as in financial documents, educational software, or any system where numbers need to be human-readable.
- Converts integers to their corresponding English words.
- Supports numbers from zero to billions.
- Handles edge cases such as zero and negative numbers.
- Simple, lightweight, and easy to integrate into any project.
Install the package via npm:
npm install int-to-words
Below is an example of how to use the int-to-words
package:
const { IntToWord } = require('int-to-words');
// Convert a number to words
const number = 1002;
const wordRepresentation = IntToWord(number);
console.log(wordRepresentation); // Outputs: "One Thousand Two."
-
Parameters:
num
(number): The number you want to convert to words.
-
Returns:
- (string): The word representation of the provided number.
const { IntToWord } = require('int-to-words');
console.log(IntToWord(123)); // Outputs: "One Hundred Twenty Three."
console.log(IntToWord(1000000)); // Outputs: "One Million."
console.log(IntToWord(100200)); // Outputs: "One Hundred Thousand Two Hundred."
console.log(IntToWord(0)); // Outputs: "Zero."
console.log(IntToWord(-1)); // Outputs: "Negative numbers are not supported."
We welcome contributions to the int-to-words
package! If you discover any issues or have ideas for improvements, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch for your feature or bugfix (
git checkout -b feature-name
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-name
). - Open a Pull Request.
This project is licensed under the ISC License. See the LICENSE file for more details.
The int-to-words
package was created to provide an easy way to convert numbers into words for various applications. We hope it simplifies your projects as much as it has for ours.