How can we build a program in which if we will put number so it will give it's spelling in JavaScript | Sololearn: Learn to code for FREE!

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

2/26/2019 4:11:55 AM

Zainab Idrees

2 Answers

New Answer

+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!

0

You can use switch/case for this purpose