how to get the last word of a string using JavaScript
how to get the last word of a string using JavaScript
Get second last word using JavaScript
const str = 'A quick brown fox jumps ver the lazy dog';
const lastWord = str.split(' ').pop();
console.log(lastWord);
const secondLast = str.split(' ')[str.split(' ').length-2];
console.log(secondLast);