Beta

English words to numbers (Part II)

Description:

This is the Part II of English words to numbers (my very first kata on CodeWars ☺). But this time we shall support up to "Nine hundred and ninety-nine vigintillion" 999x1063 (Check Names of large numbers for names of large numbers with their corresponding value). We shall be returning strings or NaN if the input doesn't evaluate to a valid number.

NOTE: we are using short scale i.e million is 106 and billion is 109.

Rules

  1. Empty string should return "0"
  2. Should support up to ± 999x1063
  3. A string equivalent of the word passed is returned e.g "one" => "1"
  4. No trailing zeros i.e. zero point zero zero one zero => "0.001" NOT "0.0010"
  5. If word starts with negative, "-" should be added to the string E.g. "negative five" => "-5"
  6. Should work with decimals. E.g. "negative twenty three point two three seven" => "-23.237"
  7. Any word that does not evaluate to a number should return NaN E.g. "thirty point ninteen" => NaN. (i.e. It should have been thirty point one nine)
  8. Words like one million three billion should return NaN (billion doesn't come after million).
  9. Words between 21 and 99 might be hypened E.g. twenty-one, fifty-seven, etc
Fundamentals
Strings

Similar Kata:

Stats:

CreatedMay 16, 2017
PublishedMay 17, 2017
Warriors Trained65
Total Skips0
Total Code Submissions315
Total Times Completed14
JavaScript Completions14
Total Stars6
% of votes with a positive feedback rating63% of 4
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments4
Average Assessed Rank
3 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
4 kyu
Ad
Contributors
  • osofem Avatar
Ad