Skip to content

Instantly share code, notes, and snippets.

@AWattNY
Created May 21, 2017 22:23
Show Gist options
  • Save AWattNY/1fae83d8de8756c9d9b946e36307e8fc to your computer and use it in GitHub Desktop.
Save AWattNY/1fae83d8de8756c9d9b946e36307e8fc to your computer and use it in GitHub Desktop.
const isPalindrome = (string) => {
const reverse = string.split('').reverse().join('');
const isPalindrome = (string === reverse);
const result = isPalindrome ? `${string} is a Palindrome` : `${string} is not a Palindrome`;
return result;
};
@lexjacobs
Copy link

Perhaps .toLowerCase() would be useful here as well.

@x5engine
Copy link

const isPalindrome = (string) => {

const reverse = string.toLowerCase().split('').reverse().join('');
const isPalindrome = (string === reverse);

const result = isPalindrome ? ${string} is a Palindrome : ${string} is not a Palindrome;

return result;

};

isPalindrome("aAbcc")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment