DEV Community

Rakesh Reddy Peddamallu
Rakesh Reddy Peddamallu

Posted on

Leetcode - 58. Length of Last Word

/**
 * @param {string} s
 * @return {number}
 */
var lengthOfLastWord = function(s) {
    let words = s.split(" ").filter((word) => word!="");
    return words.pop().length
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)