js check if character is last element in string code example
Example 1: javascript get last character in string
var hello = "Hello World";
var lastCharOfHello=hello.slice(-1);//d
Example 2: get last word in string js
function test(words) {
var n = words.split(" ");
return n[n.length - 1];
}