This is currently my code: It counts all words, however when I try to make it count all non white spaces or letters in a sentence it does not work. I am very new to Java script so all replies will help!
<body>
<p>
<textarea id="textBubble" height="500"></textarea>
</p>
<p>
<span id="charCount">0</span> Characters
</p>
<p>
<span id="nonWhiteandWhiteCharCount">0</span> Non White and White Characters
</p>
<button type="button">Submit!</button>
<script>
var textBubble = document.getElementById("textBubble");
var charCount = document.getElementById("charCount");
var nonWhite = document.getElementById("textBubble")
textBubble.addEventListener("keyup",function(){
var char = textBubble.value.split(/\s+/);
charCount.innerText = char.length;
var non = textBubble.value.split('');
nonWhite.innerText = characters.filter( item => {
return (item != ' ');
}).length;
nonWhite.innerText = non.length;
});
function duplicateCount(text) {
i = i.toLowerCase()
let obj = {}
for (let i of text) {
if (!obj[i]) {
obj[i] = 1
}
}
for (let i in obj) {
if(obj[i] > 1) {
count++
}
}
return count
}
</script>
</body>