numberInWords = n => {
let str = n.toString();
if (str.length === 4) return 'one thousand';
let singleDigit = +str[str.length - 1];
let tensDigit = +str[str.length - 2];
let hundredsDigit = +str[str.length - 3];
let single = singleDigit ? LESS_THAN_TWENTY[singleDigit] : '';
let tens = tensDigit > 1 ? TENTHS[tensDigit] : '';
let hundreds = hundredsDigit ? (single || tens)
?
LESS_THAN_TWENTY[hundredsDigit] + ' hundred and' :
LESS_THAN_TWENTY[hundredsDigit] + ' hundred'
: '';
return hundreds + ' ' + tens + single;
}