---
id: 66e2f06b191e305c00574e4d
title: Step 7
challengeType: 1
dashedName: step-7
---

# --description--

Finally, count the number of words by creating a `getWordCount` function with a `sentence` parameter. The function should return the total number of words in the sentence passed in when it is called.

# --hints--

You should create a `getWordCount` function.

```js
assert.isFunction(getWordCount);
```

Your `getWordCount` function should have a `sentence` parameter.

```js
assert.match(getWordCount.toString(), /sentence/);
```

Your `getWordCount` function should return a number.

```js
assert.isNumber(getWordCount("I love freeCodeCamp"))
```

When the sentence is `"When are you gonna start learning to code?"`, the `getWordCount` function should return `8`.

```js
assert.strictEqual(getWordCount("When are you gonna start learning to code?"), 8);
```

When the sentence is `"What's going on?"`, the `getWordCount` function should return `3`.

```js
assert.strictEqual(getWordCount("What's going on?"), 3);
```

Your word count should be case-insensitive.

```js
assert.strictEqual(getWordCount("freeCodeCamp offers free coding tutorials online"), 6);
assert.strictEqual(getWordCount("You can learn HTML, CSS, JavaScript, and more on freeCodeCamp"), 10);
```

Your `getWordCount` function should return the correct word count for any sentence.

```js
assert.strictEqual(getWordCount("freeCodeCamp has a great community of kind people"), 8);
assert.strictEqual(getWordCount("The freeCodeCamp curriculum is constantly updated"), 6);
assert.strictEqual(getWordCount("freeCodeCamp teaches both front-end and back-end development"), 7);
```

Your `getWordCount` function should return the correct word count for an empty string, or a string only with spaces.

```js
assert.strictEqual(getWordCount(""), 0);
assert.strictEqual(getWordCount("   "), 0);
```

# --seed--

## --seed-contents--

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

--fcc-editable-region--

--fcc-editable-region--
```
