문제 링크 : Length of Last Word
/**
* @param {string} s
* @return {number}
*/
var lengthOfLastWord = function(s) {
let arr = s.split(' ');
let result = 0
for(let i=arr.length-1; i>-1; i--){
if(arr[i] !== '') {
result = arr[i].length;
break;
}
}
return result;
};
/**
* @param {string} s
* @return {number}
*/
var lengthOfLastWord = function(s) {
let arr = s.split(' ').filter(e => e !== '');
return arr[arr.length-1].length;
};