0

How can we build a program in which if we will put number so it will give it's spelling in JavaScript

Like if user will give number 20 so in alert it will say twenty

26th Feb 2019, 4:11 AM
Zainab Idrees
Zainab Idrees - avatar
2 Antworten
+ 1
First, you’ll need to hard-code all the spellings: One - Nine, Ten - Ninety (by tens), Hundred, Thousand, Million.. etc. You can put these spellings in a dictionary and/or make case statements based on the length of the whole number and then iterate through each sub-number. Try an attempt, and then we can try to clean up your code!
26th Feb 2019, 5:31 AM
Nathan Lewis
Nathan Lewis - avatar
0
You can use switch/case for this purpose
26th Feb 2019, 5:32 AM
wenz
wenz - avatar