Reverse the Odd Length Words

Published by persolut in

Given a string, reverse all the words which have odd length. The even length words are not changed.

Examples

ReverseOdd("Bananas") ➞ "sananaB"

ReverseOdd("One two three four") ➞ "enO owt eerht four"

ReverseOdd("Make sure uoy only esrever sdrow of ddo length")
➞ "Make sure you only reverse words of odd length"

Notes

There is exactly one space between each word and no punctuation is used.

Watch a quick demo on how Edabit works.