I would like to know how can I remove the last word in the string using JavaScript?
For example, the string is \"I want to remove the last word.\"
After usin
var str = "I want to remove the last word."; var lastIndex = str.lastIndexOf(" "); str = str.substring(0, lastIndex);
Get last space and then get sub string.