Question 58: Length of Last Word
Link
Solution
Solution
- s.trim() helps in removing the unwanted white characters in start and in the end
- s.split(“ “), this method helps in adding the words in the sentence to the array, using space as a delimiter.
- returning the length of the word in the array word[].
Code