I developed this in a rush for a client. We work with numbers as
large as a couple of millions and that have a maximum of two
decimals. There are a severals improvements that I would like to
do (patches are welcome!) but by the moment it’s working well for
my case so I decided to jump from alpha to stable.
npm install number-to-spanish-words
const numberToSpanishWords = require('number-to-spanish-words');
numberToSpanishWords(10359); // "diez mil trecientos cincuenta y nueve"
I realised that in Spanish every number is built from cent to
cent, for example:
So first we split the number between the integer part and the
fractional part and then we process both parts the same way:
This last part is pretty ugly and I would like to improve it.
After that I would like to process bigger numbers (up to a
billón).
I plan to replace all JavaScript array methods with Ramda because
I have been surprised by some native methods that mutate the array
instead to return a new one.