Build a Sentence Analyzer - Step 3

Tell us what’s happening:

I am stuck here.
The code is given as follows.
Kindly help.

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}`);

function getConsonantCount(sentence){
  const consonant = "Thaqckbrwnfxjmpsvrthlzydg";
  let consonantCount = 0
  for (const char of sentence.toLowerCase()) {
    if (consonant !=="a" && consonant !=="e" && consonant !=="i" && consonant !=="o" && consonant !=="u") {
      consonantCount++;
    }
  }
  return consonantCount;
}
console.log(getConsonantCount("Coding is fun"))

// User Editable Region

function getConsonantCount(sentence){
  const consonant = "Thaqckbrwnfxjmpsvrthlzydg";
  let consonantCount = 0
  for (const char of sentence.toLowerCase()) {
    if (consonant !=="a" && consonant !=="e" && consonant !=="i" && consonant !=="o" && consonant !=="u") {
      consonantCount++;
    }
  }
  return consonantCount;
}
console.log(getConsonantCount("Coding is fun"))

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0

Challenge Information:

Build a Sentence Analyzer - Step 3
https://www.freecodecamp.org/learn/full-stack-developer/workshop-sentence-analyzer/step-3

what is consonant?

It is given in the code!!

Please try to answer the question. We ask questions to try to help you see how to fix your code.

Also, please note -it is much easier to help if you say what specifically is confusing and what debugging you have tried.

I see that, what I mean to ask you is, can it ever be false? can consonant ever be equal to "a"? To answer that it is important you look carefully and respond, what is consonant?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.