title: How to remove the last word in a string using JavaScript
body: <p>How can I remove the last word in the string using JavaScript?</p>
  <p>For example, the string is &quot;I want to remove the last word.&quot;</p>
  <p>After using removal, the string in the textbox will display &quot;I want to remove the last&quot;</p>
  <p>I've seen how to remove the last character using the <em>substring</em> function, but because the last word can be different every time. Is there a way to count how many words are required to remove in JavaScript?</p>