programming-examples/js/Functions/Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string..js

16 lines
321 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
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"));