Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return as dataset #14

Open
mindfullsilence opened this issue Oct 11, 2017 · 0 comments
Open

Return as dataset #14

mindfullsilence opened this issue Oct 11, 2017 · 0 comments

Comments

@mindfullsilence
Copy link

Would be great to have the option to get the words as an array so that we can construct our own joining rules easily. E.g.:

converter.toWords(9007199254740992, true); // 'true' to get return as data

Returns:

[
  'nine quadrillion', 
  'seven trillion', 
  'one hundred ninety-nine billion', 
  'two hundred fifty-four million', 
  'seven hundred forty thousand', 
  'nine hundred',
  'ninety-two'
]

Then we can do things like:

let wordsArray = converter.toWords(9007199254740992, true);
let ret1 = `There are over ${wordsArray[0]} available.`; // There are over nine quadrillion available.

or

let wordsArray = converter.toWords(1992, true);
let last = wordsArray.pop()
let ret = 'There are ' + wordsArray.join(' ') + ' and ' + last; // There are one thousand nine hundred and ninety-two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant