- 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
2 Antworten
+ 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.
+ 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.