Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 779 Bytes

is_this_my_tail.md

File metadata and controls

29 lines (22 loc) · 779 Bytes

Description

Some new animals have arrived at the zoo. The zoo keeper is concerned that perhaps the animals do not have the right tails. To help her, you must correct the broken function to make sure that the second argument (tail), is the same as the last letter of the first argument (body) - otherwise the tail wouldn't fit!

If the tail is right return true, else return false.

The arguments will always be non empty strings, and normal letters.

def correct_tail(body, tail)
   sub = body.substr(body.length-(tail.length)
  
  if sub = tail) then
    return true
  
  else 
    return false
    end

My Solution

def correct_tail(body, tail)
  body[-1] == tail
end