Tell us what’s happening:
My code is correct i guess but for the consonant count, it is counting the spaces what do i do
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");
// User Editable Region
console.log(`Vowel Count: ${vowelCount}`);
const getConsonantCount = (sentence) => {
let consonantCount = "aeiouAEIOU" ;
let count = 0 ;
for (const char of sentence){
if(consonantCount.includes(char) == false){
count ++
}
}
return count
}
console.log(getConsonantCount("Coding is fun"))
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Sentence Analyzer - Step 3