Reverse words in a string

Easy
1
100.0% Acceptance

Write a function reverseSentence(sentence) that takes a string sentence and returns the sentence with words all reversed.

Instructions

  • You can assume that the input sentence will 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'

Hints

  • It would help if you started by converting the sentence into an array of words and reversing it.