← Back to challenges

Say the Number!

JavaScriptHardalgorithmslogicnumbersdata_structures

Instructions

Create a function that takes a numeral (just digits without separators (e.g. 19093 instead of 19,093) and returns the standard way of reading a number, complete with punctuation.

Examples

sayNumber(0) ➞ "Zero."

sayNumber(11) ➞ "Eleven."

sayNumber(1043283) ➞ "One million, forty three thousand, two hundred and eighty three."

sayNumber(90376000010012) ➞ "Ninety trillion, three hundred and seventy six billion, ten thousand and twelve."

Notes

Must read any number from 0 to 999,999,999,999,999.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.