From 5af174fc5ba887ba1a480ffca215fcda1befe938 Mon Sep 17 00:00:00 2001 From: Flynn Date: Mon, 29 Jan 2024 09:26:39 +0900 Subject: [PATCH] solution: 0058. Length of Last Word --- src/0058/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/0058/index.ts b/src/0058/index.ts index b2b5063..0e293e8 100644 --- a/src/0058/index.ts +++ b/src/0058/index.ts @@ -1,3 +1,5 @@ -function lengthOfLastWord(s: string): number {} +function lengthOfLastWord(s: string): number { + return s.trimEnd().split(' ').pop()?.length ?? 0; +} export { lengthOfLastWord };