Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 504 Bytes

reversed_words.md

File metadata and controls

17 lines (12 loc) · 504 Bytes

Description

Complete the solution so that it reverses all of the words within the string passed in.

Words are separated by exactly one space and there are no leading or trailing spaces.

Example(Input --> Output):

"The greatest victory is that which requires no battle" --> "battle no requires which that is victory greatest The"

My Solution

def solution(sentence)
  sentence.split.reverse.join(' ')
end