Skip to content

Commit

Permalink
solution(javascript): 58. Length of Last Word
Browse files Browse the repository at this point in the history
58. Length of Last Word
- JavaScript
  • Loading branch information
godkingjay authored Oct 31, 2023
2 parents 97f9eb1 + 424b62a commit 541b2c5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Easy/58. Length of Last Word/Length_of_last_word.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @param {string} s
* @return {number}
*/
var lengthOfLastWord = function(s) {
s = s.trim();

const words = s.split(" ");
return words[words.length - 1].length;
};

0 comments on commit 541b2c5

Please sign in to comment.