1var str = 'mystring';
2
3// the character 'g' will be removed
4str = str.slice(0, -1);
1var str = "I want to remove the last word.";
2var lastIndex = str.lastIndexOf(" ");
3
4str = str.substring(0, lastIndex);
5
1var myString = "I want to remove the last word";
2var mySplitResult = myString.split(" ");
3var lastWord = mySplitResult[mySplitResult.length-1]
4