Skip to content

Instantly share code, notes, and snippets.

@dragonza
Last active January 28, 2018 16:13
Show Gist options
  • Save dragonza/3a3ad3caa44e7f8b6ba7a6e4c0474e3f to your computer and use it in GitHub Desktop.
Save dragonza/3a3ad3caa44e7f8b6ba7a6e4c0474e3f to your computer and use it in GitHub Desktop.
Palindrome
function palindrome(str) {
const arr = str.split(''); // turn a string in to an array of characters
return arr.every((char, i) => char === str[str.length - 1 - i]); // return true if all elements in the array pass the test implemented by the provided function.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment