Skip to content

Commit 29be565

Browse files
committed
[Shreyash]: Added code to print numbers 1, 10, 100, 1000,... in words using switch case
1 parent 8aef5f0 commit 29be565

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Read Number from (1, 10, 100, 1000, 10000) and display unit, ten, hundred,...
3+
*/
4+
5+
const prompt = require("prompt-sync")();
6+
console.log();
7+
let num = parseInt(prompt(" Enter the number from (1, 10, 100, 1000, 10000) : "));
8+
9+
switch (num) {
10+
case 1:
11+
console.log(" " + num, ": Unit \n");
12+
break;
13+
case 10:
14+
console.log(" " + num, ": Ten \n");
15+
break;
16+
case 100:
17+
console.log(" " + num, ": One Hundred \n");
18+
break;
19+
case 1000:
20+
console.log(" " + num, ": One Thousand \n");
21+
break;
22+
case 10000:
23+
console.log(" " + num, ": Ten Thousand \n");
24+
break;
25+
default:
26+
console.log(" Invalid Number \n");
27+
break;
28+
}

0 commit comments

Comments
 (0)