title: How do i make a simple word counter in javascript and display it to a <p> tag
body: <pre><code>function countWords(){
      var sentence = document.getElementById(&quot;sentence-input&quot;).value;
  
      var text = sentence.split(&quot; &quot;);
  
      var lengthofString = text.length;
  
      document.getElementsByClassName(&quot;word-count&quot;).innerText = lengthofString;
  
      console.log(text);
      console.log(&quot;length of string &quot; + lengthofString);
  
  }
  </code></pre>
  <p>Here is my current code, I'm able to get the length of the current string but i dont know how to simply display that number in my paragraph element.</p>