Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 499 Bytes

remove_first_and_last_character.md

File metadata and controls

18 lines (16 loc) · 499 Bytes

Description

It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less than two characters.

My Solution

def remove_char(s)
  s[1..-2]
end

Better/Alternative solution from Codewars

def remove_char(s)
  s[1...-1]
end