Can some answer this please?

Continuing the discussion from freeCodeCamp Algorithm Challenge Guide: Check for Palindromes:

can someone answer this please?

I notice you didn’t use { } after your if statement. How does that affect the outcome?

When only a single line of code needs to be executed, then you can omit the curly braces. Many people will encourage you to use them anyway to make code more readable. The front++ and back-- are not part of the if block.

Because when I use the { } it says that it cant do the increment front++ and back-- because it is returning

My guess is that you are including the increments and decrements in your code block. Remember that once a return statement is executed, that’s the end of the function. In the code that you copied, the increment and decrement only occur if the condition is false.

But why increment after returning false or true?
It doesn’t. If the condition is true (the letters don’t match) then it returns false and nothing else happens. We know it is not a palindrome. There is no return true statement. It keeps going until either a mismatch is found (returns false) or the whole string has been checked (then we know it’s a palindrome).