Length of Last Word
LeetCode題目: 58. Length of Last Word
My solution:
/**
* @param {string} s
* @return {number}
*/
let lengthOfLastWord = s => s.trim().replace(/\s+/g, ' ').split(' ').pop().length;
LeetCode題目: 58. Length of Last Word
My solution:
/**
* @param {string} s
* @return {number}
*/
let lengthOfLastWord = s => s.trim().replace(/\s+/g, ' ').split(' ').pop().length;