DEV Community

loading...

Discussion on: Daily Challenge #15 - Stop gninnipS My sdroW!

Collapse
scrabill profile image
Shannon Crabill

Ruby

def wordSpinner(string)
  string.split(" ").map do |word|
    if word.length >= 5
      word.reverse
    else
      word
    end
  end.join(" ")
end

Tests

wordSpinner("Everything small is just a smaller version of something big")
wordSpinner("Bad biscuits make the baker broke bro")
wordSpinner("Sometimes life is scary and dark")

Results

"gnihtyrevE llams is just a rellams noisrev of gnihtemos big"
"Bad stiucsib make the rekab ekorb bro" 
"semitemoS life is yracs and dark"