Check for Palindromes help1

Tell us what’s happening:
I don’t even know where to start…

Your code so far

function palindrome(str) {
  // Good luck!

  return true;
}



palindrome("eye");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36.

Link to the challenge:

You just need to check if the las letter is the same as the first letter and put it inside of a loop. Like

int i = 0;
int j = str.length() -1;
while(i < j)
{
if( str.charAt(i++) != charAt(j--) ) //Checking two letters, the first and the last.
//If the letter were different it would return false
//In any case the variable i will be incremented by 1 and j decreased by 1
return false;
}
return true; //Only if all the letters match.

I think this would work.
Sorry i’m hurry and i can’t check or explain you more. I hope that it works and you understand it.

Try to break the problem up into smaller problems.

Firstly, a palindrome reads the same forward as it does backwards…so, do you know how to see if one string is the same as another one?

Do you know how to reverse a string, or can you think of a way you might do that?

Once you solve those mini problems, you will need to think about how you handle special characters such as the spaces and dashes.

Take your time :slight_smile: