1var str = "Hello";
2var newString = str.substring(0, str.length - 1); //newString = Hell
1// Get last n characters from string
2var name = 'Shareek';
3var new_str = name.substr(-5); // new_str = 'areek'
1// strips all punctuation and returns the last word of a string
2// hyphens (-) aren't stripped, add the hyphen to the regex to strip it as well
3function lastWord(words) {
4 let n = words.replace(/[\[\]?.,\/#!$%\^&\*;:{}=\\|_~()]/g, "").split(" ");
5 return n[n.length - 1];
6}