+ 1
7. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. Note : A
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 Respuestas
+ 2
i will not write code but just give u idea
make a variable having value of that string.
then iterate over string using another variabke lets say i.
we also have to count so initialise a counter above with 0.
and inside of loop check whether array[i]==='a'.
if yes then increment counter.
similarly check for capital A.
and this process can be repeated for all vowels.
u can optimise this also accordingly
+ 1
No, i is a string not an array. To make it an array, you can do var iArr = i.split("") so each and every of the characters becomes a member of an array.