logo

Is it a palindrome?

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


My code:

function isPalindrome(x) {
                        let normal = x.toString().toLowerCase();
                        let reverse = normal.split('').reverse().join('').toLowerCase();
                        if (normal === reverse) {
                          return true;
                        } else {
                          return false;
                        }
                      }
                        
                    


And that's the best solution among all users:

const isPalindrome = (x) => {
                        return x.split("").reverse().join("").toLowerCase() === x.toLowerCase() ? true : false
                      }