Build a Sentence Analyzer - Step 1 (Cultural issue)

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

As an extra note, I noticed it was referenced instead in Step 3 for the consonant exercise:

A consonant is any letter that is not one of the following characters: "aeiou".

I believe it makes it yet another reason to move it earlier in the steps.

Welcome to the forum @Izuka !

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

Happy coding!