Tell us what’s happening:
Hi guys!
I’ve implemented a function that takes in sentence parameter and checks if the sentence character is a consonant and add 1 into the count variable. For some reason, my code is not passing. Am I missing something?
Your code so far
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}`);
// User Editable Region
const getConsonantCount = sentence => {
const consonant = "bcdfghjklmnpqrstvwyz";
let count = 0;
for(const char of sentence.toLowerCase()) {
if(consonant.includes(char)) {
count++
}
}
return count
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Challenge Information:
Build a Sentence Analyzer - Step 3