Last active
November 13, 2016 13:07
-
-
Save umair-khanzada/614f4ee202b6f1337bd0b2fd8e68cbf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lsb = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'saven', 'eight', 'nine'], | |
mid = ['', 'ten', 'tweenty', 'therty', 'fourty', 'fifty', 'sixty', 'saventy', 'eighty', 'ninty'], | |
msb = ['', 'one hundred', 'two hundred', 'three hundred', 'four hundred', 'five hundred', 'six hundred', 'saven hundred', 'eight hundred', 'nine hundred'], | |
num = 445; | |
input = String(num); | |
let msbBit = Number(input[0]), | |
midBit = input.length > 1 ? Number(input[1]) : 0, | |
lsbBit = input.length > 2 ? Number(input[2]) : 0; | |
let result = `${msb[msbBit]} ${mid[midBit]} ${lsb[lsbBit]}`; | |
//result "four hundred fourty five" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment