diff --git a/Easy/58. Length of Last Word/Length_of_last_word.js b/Easy/58. Length of Last Word/Length_of_last_word.js new file mode 100644 index 00000000..1b78d3b0 --- /dev/null +++ b/Easy/58. Length of Last Word/Length_of_last_word.js @@ -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; +};