- 1

7. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. Note :

7. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. Note : As the letter 'y' can be regarded as both a vowel and a consonant, we do not count 'y' as vowel here. Example string : 'The quick brown fox' Expected Output : 5

18th Dec 2016, 9:23 PM
Nashwan Aziz
Nashwan Aziz - avatar
2 Respuestas
+ 4
dude, you won't be a good programmer, if you want others to make your homework. try to find out by yourself first. even if you google that, try to understand what is going on in the code and why.
18th Dec 2016, 10:03 PM
Demeth
Demeth - avatar
+ 3
function countVowels(str) { return str.match(/[aeiou]/gi).length } BTW, please don't spam the Q&A Discussions with questions which seem like your assignment.
19th Dec 2016, 1:39 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar