find vowel in js code example
Example 1: find the vowel js
function vowel_count(str1)
{
var vowel_list = 'aeiouAEIOU';
var vcount = 0;
for(var x = 0; x < str1.length ; x++)
{
if (vowel_list.indexOf(str1[x]) !== -1)
{
vcount += 1;
}
}
return vcount;
}
console.log(vowel_count("The quick brown fox"));
Example 2: find vowel & consonants in a string java script
const str = "The quick brown fox jumps over a lazy dog";
const vowels = str.match(/[aeiou]/gi);
const consonants = str.match(/[^aeiou]/gi);
vowels.concat([''],consonants).forEach(k => { console.log(k); } );
Example 3: find vowels in string javascript
var name = userInput[0];
var count =0;
function findvowel(name)
{
var vowel = ['a','e','i','o','u','A','E','I','O','U'];
for(i=0;i<name.length;i++)
{
if(vowel.includes(name[i]))
{
count++;
}
}
return count;
}
console.log(findvowel(name));