Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript remove last word from string

var str = "I want to remove the last word.";
var lastIndex = str.lastIndexOf(" ");

str = str.substring(0, lastIndex);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #remove #word #string
ADD COMMENT
Topic
Name
5+5 =