Build a Sentence Analyzer - Step 3

Tell us what’s happening:

Hi guys!

I’ve implemented a function that takes in sentence parameter and checks if the sentence character is a consonant and add 1 into the count variable. For some reason, my code is not passing. Am I missing something?

Your code so far

function getVowelCount(sentence) {
  const vowels = "aeiou";
  let count = 0;

  for (const char of sentence.toLowerCase()) {
    if (vowels.includes(char)) {
      count++;
    }
  }
  return count;
}

const vowelCount = getVowelCount("Apples are tasty fruits");
console.log(`Vowel Count: ${vowelCount}`);


// User Editable Region

const getConsonantCount = sentence => {
  const consonant = "bcdfghjklmnpqrstvwyz";
  let count = 0;
  for(const char of sentence.toLowerCase()) {
    if(consonant.includes(char)) {
      count++
    }
  }
  return count
}




// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Build a Sentence Analyzer - Step 3

You are missing one letter in the consonant list, you have 20 letters in there, there should be 21 (26 - 5)

the sentence you are failing with is the pangram (means it contains all the letters of the alphabet) "The quick brown fox jumps over the lazy dog", there are 24 consonants but your code finds only 23