Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 571 Bytes

is_it_a_palindrome.md

File metadata and controls

22 lines (19 loc) · 571 Bytes

Description

Write a function that checks if a given string (case insensitive) is a palindrome.

A palindrome is a word, number, phrase, or other sequence of symbols that reads the same backwards as forwards, such as madam or racecar.

My Solution

def is_palindrome(str)
  str.downcase!
  str == str.reverse
end

Better/Alternative solution from Codewars

def is_palindrome str
  str.casecmp?(str.reverse)
end