
numberToWordsJS is a simple yet useful JavaScript library for converting numbers into words equivalent. Supports both positive and negative integers.
See Also:
How to use it:
Installation:
# NPM $ npm install num-to-words --save
Import the module.
const numToWords = require('num-to-words');Or load the numberToWords.js into your html page when needed.
<script src="numberToWords.js"></script>
Create an input field to accept numeric values.
<input type="text" id="input">
Create a container element to output the words equivalent.
<p id="output"></p>
The main JavaScript to active the numbers to words converter.
var input = document.getElementById('input');
var output = document.getElementById('output');
input.addEventListener('input', function () {
output.innerHTML = numberToWords(parseInt(input.value, 10));
});Changelog:
08/12/2018
- Rewritten in ES6







