I am supposed to write a function which can count the words in the text area but my code count only the first word, you can see the code here:
var myTextareaElement = document.getElementById("myWordsToCount");
myTextareaElement.onkeyup = function wordcount(wor){
var myTextareaElement =document.getElementById("myWordsToCount").value;
var haveByNow = 0;
for (var i = 0; i < wordcount.length; i++)
if (wor[i] === " ") {
haveByNow = +1;
}
haveByNow += 1;
document.getElementById("wordcount").innerHTML = haveByNow;
}