I want to fetch last word dynamically

chandan86patra
Tera Contributor

Hi All ,

 

I want to fetch the last word from the short description and store in the one of the variable :

var gr= current.short_description;


var words = s.trim().split(gr);
var lengthOfLastWord = words[words.length - 1];
gs.print(lengthOfLastWord); 

 

var ab=lengthOfLastWord;

 

This script is not fetching the last word .Can anyone help me .

 

Thanks and Regards,

Chandan