FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 59   



Following program shows you how to take a character and tells its vowel or consonant.
In this program we get a character from user and shows it's vowel or consonant using if condition

var input = prompt("Enter a character:");
if (input == 'a' || input == 'A' || input == 'e' || input == 'E' || input == 'i' || input == 'I' || input == 'o' || input == 'O' || input == 'u' || input == 'U') {
console.log("Its a vowel");
} else if ((input >= 'a' && input <= 'z') || (input >= 'A' && input <= 'Z')) {
  console.log("Its a consonant");
} else {
    console.log("Invalid input please enter an alphabet");
 }

Output:

Example1:

Enter a character:
a
Its a vowel

Example2:

Enter a character:
y
Its a consonant

Example3:

Enter a character:
-2
Invalid input please enter an alphabet



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News