curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2e99caa0cb3570f4822b4.md
Now it is time to test your getConsonantCount function.
Create a consonantCount variable and assign it the result of calling the getConsonantCount function with the argument of "Coding is fun"
After that, log the following to the console: "Consonant Count: [Consonant count goes here]". Replace [Consonant count goes here] with the actual variable name. You can choose to use template strings or string concatenation with the + operator here.
You should create a consonantCount variable.
assert.isNotNull(consonantCount)
Your consonantCount variable should be set to the result of getConsonantCount("Coding is fun").
assert.equal(consonantCount, getConsonantCount("Coding is fun"));
You should log the consonantCount variable to the console with the parameter "Consonant Count: ${consonantCount}".
assert.match(code, /console\.log\((?:('|"|`)Consonant\s+Count:\s+('|"|`)\s+\+\s+consonantCount|`Consonant\s+Count:\s+\${consonantCount}`)\);?/)
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;
}
--fcc-editable-region--
--fcc-editable-region--