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;
profile-image
Hi, 我是 Zeki。目前為一名前端工程師。我相信科技始終來自於人性,是用來幫助人們過上更有品質的生活的,但願也希望如此。