Build a Sentence Analyzer - Step 2

Tell us what’s happening:

Hello guys i really dont know what to do now, it asks mme to use the bracket notation, but when i use the ++ the result is correct. What should i do

Your code so far

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

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

// User Editable Region

  return count;
}

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

// 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

Challenge Information:

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

Hi. You need to use the template literal method correctly. Have a quick refresher on this and tweak your console log

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

ive changed it but it still doesnt work

The text of your message needs to be exact including punctuation. Check yours against the text asked for character for character.

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

it still has no change

Your punctuation / lack of is not the same as in the instructions. You need to have everything inside the grey shaded area.

Try it without template literals if it still doesn’t work. When I test your code it is telling me your quotes are back ticks are unexpected characters so I need to change them to make it pass. That might just be me. Still need to sort the text itself though

1 Like

what do you see in the console? what is this printing?
now your puctuation seems to match, but there is a bigger issue at hand

yooh thanks man, i finally figured it out i was using the wrong punctuation

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like