diff --git a/lib/palindrome_check.rb b/lib/palindrome_check.rb index d60efd0..174b4c9 100644 --- a/lib/palindrome_check.rb +++ b/lib/palindrome_check.rb @@ -1,5 +1,24 @@ # A method to check if the input string is a palindrome. # Return true if the string is a palindrome. Return false otherwise. +require 'pry' def palindrome_check(my_phrase) - raise NotImplementedError + if my_phrase == nil + return false + end + i = 0 + j = my_phrase.length - 1 + while i < j do + until my_phrase[i] != " " + i +=1 + end + until my_phrase[j] != " " + j -= 1 + end + if my_phrase[i] != my_phrase[j] + return false + end + i += 1 + j -= 1 + end + return true end