Tell us what’s happening:
How so i detect a sentence full of spaces? This seems to skip every 2nd index?
Your code so far
function getWordCount(sentence){
let wordCount = sentence.split(" ")
for (let char in wordCount){
if (wordCount[char]== ''){
wordCount.splice([char], 1)
}
}
return wordCount.length
}
console.log(getWordCount(" a"))
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (iPad; CPU OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/145.0.7632.108 Mobile/15E148 Safari/604.1
Challenge Information:
Build a Sentence Analyzer - Step 7