curriculum/challenges/english/blocks/workshop-sentence-analyzer/66e2eab8a5638f57b637b7cc.md
You should count the number of punctuations now.
Create a getPunctuationCount function with a sentence parameter.
Inside the function, create a loop to count the number of punctuation characters in the sentence that will be passed into the function when it is called. For our purposes, a punctuation character is any character that is not a space (" ") or a letter.
Your getPunctuationCount function must return a number.
You should create a getPunctuationCount function.
assert.isFunction(getPunctuationCount);
Your getPunctuationCount function should have a sentence parameter.
assert.match(getPunctuationCount.toString(), /sentence/);
Your getPunctuationCount function should return a number.
assert.isNumber(getPunctuationCount("Coding is fun!"))
When the sentence is "What's going on here?", the getPunctuationCount function should return 2.
assert.strictEqual(getPunctuationCount("What's going on here?"), 2);
When the sentence is "What????!", the getPunctuationCount function should return 5.
assert.strictEqual(getPunctuationCount("What????!"), 5);
Your getPunctuationCount function should return the correct punctuation count for any sentence.
assert.strictEqual(getPunctuationCount("Be quick, sign up! freeCodeCamp awaits, friend!!!"), 6);
assert.strictEqual(getPunctuationCount("Guess what? freeCodeCamp is launching a new cert soon!"), 2);
assert.strictEqual(getPunctuationCount("freeCodeCamp, again? It's incredible!"), 4);
assert.strictEqual(getPunctuationCount(""), 0);
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}`);
--fcc-editable-region--
--fcc-editable-region--