# Build a Sentence Analyzer - Step 7

**URL:** <https://forum.freecodecamp.org/t/build-a-sentence-analyzer-step-7/800400>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 17, 2026, 6:24am UTC](https://forum.freecodecamp.org/t/build-a-sentence-analyzer-step-7/800400 "2026-09-17T06:24:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![verver](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/verver/32/382053_2.png) [@verver](https://forum.freecodecamp.org/u/verver)\
**Post date:** [September 17, 2026, 6:24am UTC](https://forum.freecodecamp.org/t/build-a-sentence-analyzer-step-7/800400/1 "2026-09-17T06:24:59Z")

</div>

### Tell us what’s happening:

I dont know why it isn’t working though it gives the word count

### Your code so far

```js
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 consonants = "bcdfghjklmnpqrstvwxyz";
  let count = 0;

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

const consonantCount = getConsonantCount("Coding is fun");
console.log(`Consonant Count: ${consonantCount}`);

function getPunctuationCount(sentence) {
  const punctuations = ".,!?;:-()[]{}\"'–";
  let count = 0;

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

const punctuationCount = getPunctuationCount("WHAT?!?!?!?!?");
console.log(`Punctuation Count: ${punctuationCount}`);

// User Editable Region
function wordCounter(sentence) {
  let count = 0;
  let spaces = sentence.trim().split(" ");

  for (let a = 0; a < spaces.length; a++) {
    if(spaces !== '')
    {
    count++;
    }
  }
  return count;
}
// User Editable Region

```

### Your browser information:

User Agent is: `Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:155.0) Gecko/20100101 Firefox/155.0`

### Challenge Information:

Build a Sentence Analyzer - Step 7

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-v9/workshop-sentence-analyzer/step-7)**
>
> Learn to Code for Free

GitHub Link: [freeCodeCamp/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f06b191e305c00574e4d.md at main · freeCodeCamp/freeCodeCamp · GitHub](https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2f06b191e305c00574e4d.md)

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [September 17, 2026, 12:30pm UTC](https://forum.freecodecamp.org/t/build-a-sentence-analyzer-step-7/800400/2 "2026-09-17T12:30:13Z")

</div>

Hi @verver,

> count the number of words by creating a `getWordCount` function with a `sentence` parameter

> [@verver](#):
>
> `function wordCounter(sentence) {`

Have you implemented the above instruction as asked?

Add a log inside your function so you can see what it’s doing: `console.log("spaces",spaces)`

And test what your function returns by calling it: `console.log("Word Count:", getWordCount(""))`

Happy coding
