FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 52   



Following program shows you how to take a number between 0 to 9 and print the word representation for that number.
In this program we get numbers between 0 to 9 from user and print word representation using if condition

var input = prompt("Enter a number between 0 to 9:");
if (input == 0) {
    console.log("Zero");
} else if (input == 1) {
    console.log("One");
} else if (input == 2) {
    console.log("Two");
} else if (input == 3) {
    console.log("Three");
} else if (input == 4) {
    console.log("Four");
} else if (input == 5) {
    console.log("Five");
} else if (input == 6) {
    console.log("Six");
} else if (input == 7) {
    console.log("Seven");
} else if (input == 8) {
    console.log("Eight");
} else if (input == 9) {
    console.log("Nine");
} else {
    console.log("We don't have word representation for that number");
}

Output:

Example1:

Enter a number between 0 to 9:
3
Three

Example2:

Enter a number between 0 to 9:
8
Eight

Example3:

Enter a number between 0 to 9:
-2
We don't have word representation for that number



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News