Write a method that takes a string and returns true if it is a palindrome. A palindrome is a string that is the same whether written backward or forward. Assume that there are no spaces; only lowercase letters will be given.

This is my answer that actually passed all the test cases:

Screen Shot 2016-08-11 at 5.10.13 PM

This was my original solution.  Still not sure why it did not work.  (It returned true even for non-palindrome test cases):

Screen Shot 2016-08-11 at 5.11.31 PM

Provided solution:

Screen Shot 2016-08-11 at 5.12.02 PM

Second time doing this:


I forgot the ‘return true’ at the end.  Always put that in there.  Don’t assume that it’ll return true if otherwise.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s