Converting numbers 1-99 to Spanish in Javascript I have written a small program to convert numeric cardinal numbers (i.e, 4, 35) into Spanish. Currently, it only supports numbers 1-99, however I would like to increase it to support numbers of any length. 

Before I do this, I am seeking some feedback on my code structure. I feel that I have too many if statements and do not abstract my code enough, and I do not wish for it to be an elongated nightmare of if statements. I am also unsure how I should split up numbers of different sizes, and what variable names to use.

getSpanishCardinal = cardinal =&gt; {
  if (0 &lt;= cardinal &amp;&amp; cardinal &lt;= 15) {
    return getCardinals()[cardinal];
  }
  if (16 &lt;= cardinal &amp;&amp; cardinal &lt;= 19) {
    return sixteenToNineteen(cardinal);
  }
  if (cardinal &gt;= 20 &amp;&amp; cardinal &lt;= 99) {
    return twentyToNinetynine(cardinal);
  }
};

twentyToNinetynine = cardinal =&gt; {
  if (cardinal % 10 == 0) {
    return getCardinals()[cardinal];
  }
  if (21 &lt;= cardinal &amp;&amp; cardinal &lt;= 29) {
    return "veinti" + getSpanishCardinal(rightMostDigit(cardinal)).toString();
  }
  return (
    getCardinals()[leftMostMultiplier(cardinal)].toString() +
    " y " +
    getSpanishCardinal(rightMostDigit(cardinal)).toString()
  );
};

sixteenToNineteen = cardinal =&gt; {
  let rightMost = rightMostDigit(cardinal);
  return "dieci" + getSpanishCardinal(rightMost).toString();
};

leftMostMultiplier = cardinal =&gt; {
  let newDigit = cardinal.toString()[0];
  const cardinalString = cardinal.toString();
  const length = cardinalString.length;
  for (let i = 1; i &lt; length; i++) {
    newDigit += "0";
  }
  return parseFloat(newDigit);
};

rightMostDigit = cardinal =&gt; {
  return cardinal % 10;
};

getCardinals = () =&gt; {
  return {
    0: "cero",
    1: "uno",
    2: "dos",
    3: "tres",
    4: "cuatro",
    5: "cinco",
    6: "seis",
    7: "siete",
    8: "ocho",
    9: "nueve",
    10: "diez",
    11: "once",
    12: "doce",
    13: "trece",
    14: "catorce",
    15: "quince",
    20: "veinte",
    30: "treinta",
    40: "cuarenta",
    50: "cincuenta",
    60: "sesenta",
    70: "setenta",
    80: "ochenta",
    90: "noventa",
    100: "cien",
    200: "doscientos",
    300: "trescientos",
    400: "cuatrocientos",
    500: "quinientos",
    600: "seiscientos",
    700: "setecientos",
    800: "ochocientos",
    900: "novecientos",
    1000: "mil",
    1000000: "millón"
  };
};

console.log(getSpanishCardinal(56));
The function declarations are at least lacking a const statement (or let or var if you prefer):

const getSpanishCardinal = cardinal =&gt; {


However I would suggest to using regular function statements instead.



The getCardinals function is a bit pointless. A simple constant instead would make more sense:

const CARDINALS =  {
  0: "cero",
  1: "uno",
  // ...
}


For readability I'd also suggest to split it up into separate objects for 0 to 15, the tens, the hundreds, etc. 

This would also allow to assign assign the tens to the base number e.g.: 

const TENS = {
     2: "veinte",
     3: "treinta",
     4: "cuarenta",
     // ...
}


and then you don't need to "build" numbers in leftMostMultiplier:

const twentyToNinetynine = cardinal =&gt; {
  // ...
  return (
    TENS[cardinal / 10] +
    " y " +
    getSpanishCardinal(rightMostDigit(cardinal))
  );
};


(BTW, there seem to be a lot of unnessecary toString()s.)