Build a Sentence Analyzer - Step 3

Tell us what’s happening:

I don’t understand why there is an error with the if bracket, could you help a little? Thanks.

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

function getConsonantCount(sentence){
let count = 0;

for (const char of sentence.toLowerCase()){
if (char != "a" || char != "e" || char != "i" || char != "o" || char != "u" ||) {
  
  count++;
  
  }else{console.log("Errorrrrrr")}

return count;
}


}

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/143.0.0.0 Safari/537.36 Edg/143.0.0.0

Challenge Information:

Build a Sentence Analyzer - Step 3

Looking at the 23th line:

if (/* snip */ char != "u" ||) {

Notice that last part inside of the parenthesis is ||, this makes JavaScript expect another condition. Since there’s none, it causes the error.

Thanks, still iy give just 1, any idea why?

I’m not sure I understand, could you rephrase the question?

if you have a this is true because even if char != "a" is false, char != "e" is true

also, notice your return and consider what happens when your return is reached