How to use array and Array .includes() method In Javascript
In this method, we will use JavaScript array of vowels and use includes method to check if given character is present in the array then it is a vowel and consonant otherwise.
Example: In this example, we will check if vowels array includes the input cahracter or not.
function checkChar(char){
ch = char.toLowerCase();
const arr = ['a','e','i','o','u']
if(arr.includes(ch))
return console.log("Given character is a Vowel");
return console.log("Given character is a Consonent");
}
checkChar('E');
checkChar('J');
Output
Given character is a Vowel Given character is a Consonent
JavaScript Program to Find if a Character is a Vowel or Consonant
In this article, we will see different approaches to finding whether a character is a vowel or a consonant using JavaScript. We will check the condition of a character being Vowel and display the result.