Accept a character from the user and check whether the character is a vowel or consonant

Table of Content - 

  1.  We are taking input from the user. 
  2. Process the input  
  3. Match this input with an array of vowel
  4. If matched then it's a vowel otherwise consonant
Let's start code form here ---

source code -

Check Enter Value is vowels or consonant!

Enter any character


<h1>Check Enter Value is vowels or consonant!</h1>

<p>Enter any character <input type="text" id="vowelsCheck" value="a" onkeyup="myFunction()"  oninput="this.value = this.value.replace(/[^a-zA-Z]/g, '').replace(/(\..*)\./g, '$1');"></p>



<p id="output"></p>

<script>
 const vowels = ['a','e','i','o','u','A','E','I','O','U'];

function checkvowels(Vchar) {
  return Vchar == document.getElementById("vowelsCheck").value;
}

function myFunction() {

if(vowels.find(checkvowels)!=undefined){
  document.getElementById("output").innerHTML = vowels.find(checkvowels)+"  is vowels!";
}else{
document.getElementById("output").innerHTML = document.getElementById("vowelsCheck").value +" is a consonants";
}

}
myFunction();
</script>