Get the name of a number, even if it's stupidly big.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

27 lines
525 B

  1. import { Digit } from '../../../common'
  2. import ones from '../base/ones'
  3. import tenPlus from '../base/tenPlus'
  4. import getBaseTenTimesName from '../base/tenTimes'
  5. interface Tens {
  6. (x10: Digit, x1: Digit): string
  7. }
  8. const tens: Tens = (x10, x1) => {
  9. switch (x10) {
  10. case 0:
  11. return ones(x1)
  12. case 1:
  13. if (x1 > 0) {
  14. return tenPlus(x1)
  15. }
  16. break
  17. default:
  18. break
  19. }
  20. return x1 > 0 ? [getBaseTenTimesName(x10), ones(x1)].join(' ') : getBaseTenTimesName(x10)
  21. }
  22. export default tens