DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
thepeoplesbourgeois profile image
Josh • Edited

Trivial in Ruby:

def double_chop(string)
  return string if string.length <= 2
  string[1..-2]
end

double_chop("hello world") # => "ello worl"
double_chop("book")        # => "oo"
double_chop("OOP")         # => "O"
double_chop("hi")          # => "hi"