Created
November 14, 2018 01:17
-
-
Save dannysmith/4061f507e84dc52ece47abe576165d72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reverse_alternate(string) | |
| # 1. Break the string down into an array of words. | |
| # 2. Loop over each word in the array. | |
| # - if the index is odd, change the word so it is reversed. | |
| # - if the index is even, leave it as it is. | |
| # 3. | |
| end | |
| reverse_alternate('one two three four') #=> 'one owt three ruof' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment