Skip to main content
2 of 3
added 290 characters in body
Emanuele Paolini
  • 2.1k
  • 1
  • 14
  • 14

I would define DECADES[0] as "" instead of "zero" so that the if (tens>0) can be removed. Notice that DECADES[0] was never used and its value "zero" was a repetition with respect to SUBTWENTY[0].

Also there is a repetition in the creation of the "subhundred" part of the number.

In fact you can safely remove this part of code:

    if (value < SUBTWENTY.length) {
        return SUBTWENTY[value];
    }

which is anyway correctly handled by the code following.

Emanuele Paolini
  • 2.1k
  • 1
  • 14
  • 14