Number Parser

In this challenge we want to convert a string into an integer. The strings simply represent the numbers in words.

Examples:

"one" => 1
"twenty" => 20
"two hundred forty-six" => 246
"seven hundred eighty-three thousand nine hundred and nineteen" => 783919

Additional Notes:

The minimum number is "zero" (inclusively)
The maximum number, which must be supported is 1 million (inclusively)
The "and" in e.g. "one hundred and twenty-four" is optional, in some cases it's present and in others it's not
All tested numbers are valid, you don't need to validate them

Using the tests

Some example tests have already been created for you. You only need make them pass. You can get started by running the following commands:

  1. Clone the repo: git clone git@github.com:wvmitchell/number-parser.git
  2. Move in and install dependencies: cd number-parser && npm i
  3. Run the tests: npm test
  4. Alternatively, run the tests in watch mode: npm run test:watch
  5. Make the first test pass, then move on to the first skipped test

Important notes

  1. Other than unskipping tests, you do not need to alter the test file.

Submitting your solution

  • Open up a pull request to this repo using a forked copy of the repo to your own Github account. Once you've done that, drop a message in the #frontend channel linking us to your PR.