Get the name of a number, even if it's stupidly big.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.

35 righe
712 B

  1. import getHundredName from './getHundredName'
  2. import NAMES from './names.json'
  3. import getBaseHundredUnit from './getBaseHundredUnit'
  4. interface GetThousandName {
  5. (hundreds: number, tens: number, ones: number): string,
  6. }
  7. const getThousandName: GetThousandName = (hundreds, tens, ones) => {
  8. if (hundreds === 0) {
  9. return getHundredName(tens, ones)
  10. }
  11. if (tens === 0 && ones === 0) {
  12. return getBaseHundredUnit(hundreds)
  13. }
  14. if (tens === 0) {
  15. return [
  16. getBaseHundredUnit(hundreds),
  17. NAMES.and,
  18. NAMES.base.units[ones],
  19. ]
  20. .join(' ')
  21. }
  22. return [
  23. getBaseHundredUnit(hundreds),
  24. getHundredName(tens, ones),
  25. ]
  26. .join(' ')
  27. }
  28. export default getThousandName