Tell us what’s happening:
I had a hard time validating this simple exercise, and it was due to a cultural difference.
The issue was with the following test:
When the sentence is “Apples are tasty fruits”, the getVowelCount function should return 7.
However, in many other languages than English, the answer would be 8, as “y” is considered a vowel, and it’s not common knowledge that it isn’t the case in English. I think changing the wording of this step to emphasize this fact would save some time for many learners!
Your code so far
// User Editable Region
const vowels = ['a', 'i', 'u', 'e', 'o', 'y'];
function getVowelCount(sentence)
{
let amount = 0;
for(let i = 0; i < sentence.length; i++)
{
if(isAVowel(sentence[i]))
amount++;
}
return amount;
}
function isAVowel(character)
{
return vowels.includes(character.toLowerCase());
}
console.log(getVowelCount("Apples are tasty fruits"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Challenge Information:
Build a Sentence Analyzer - Step 1