function processWords(){
text = document.getElementById("inputText").value;
text = text.replace(/(^\s*)|(\s*$)/gi,"");
text = text.replace(/[ ]{2,}/gi," ");
text = text.replace(/\n /,"\n");
document.getElementById("wordcount").value = text.split(' ').length;
}
<textarea name="inputText" cols="50" rows="4">
Enter text here
</textarea>
<input type="button" name="Convert" value="Process Words"
onClick="processWords();">
<input name="wordcount" type="text" value="" size="6">
I encountered an Uncaught TypeError: Cannot read property 'value' of null.
Can anyone assist me in resolving this issue?