Reverse words in a string
Write a function
reverseSentence(sentence) that takes a string
sentence and returns the sentence with words all reversed.
- You can assume that the input
sentencewill always be a sequence of words separated by one whitespace.
Example test cases
reverseSentence('hello world') // Output: 'world hello' reverseSentence('how are you') // Output: 'you are how' reverseSentence('reacterry') // Output: 'reacterry'
- It would help if you started by converting the sentence into an array of words and reversing it.