I have doubt in this

Question 2:
// var enteredAlphabet = ‘d’ or “D”
// Write a program to check vowel, consonant or non-alphabet using switch case. Change value of enteredAlphabet and check if your code works fine.

1 Like

@satishnelge2001 , You can try this way

var enteredAlphabet = "d";
var enteredAlphabet1 = enteredAlphabet.toLowerCase();
var result;
switch (enteredAlphabet1) {
  case "a":
    result = true;
    break;
  case "e":
    result = true;
    break;
  case "i":
    result = true;
    break;
  case "o":
    result = true;
    break;
  case "u":
    result = true;
    break;
}
if (result == true) {
  console.log("Enterd Alphabet", enteredAlphabet, " is a vowel");
} else {
  if (
    (enteredAlphabet >= "a" && enteredAlphabet <= "z") ||
    (enteredAlphabet >= "A" && enteredAlphabet <= "Z")
  ) {
    console.log("Entered Alphabet", enteredAlphabet, " is a Consonant");
  } else {
    console.log("Entered Alphabet", enteredAlphabet, " is a non-alphabet");
  }
}

1 Like