Hello guys! kindly help see where my silent bug is hiding

function getConsonantCount(sentence){

if(typeof sentence !== “string” || sentence !== “”) return null;

let vowels = “aeiou”;

return sentence.toLowerCase().split(“”).reduce((acc, cur) => {

if(!vowels.includes(cur) && /^[a-z]$/.test(cur)){

return acc + 1;

}

return acc

}, 0);

}

console.log(`Consonant count: ${getConsonantCount(“Hello World”)}`)

Welcome to the forum @Admiral-401

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Happy coding

1 Like

Are you sure this is the condition you want to check?

1 Like