Skip to content

Instantly share code, notes, and snippets.

@hhenrichsen
Created January 23, 2019 02:32
Show Gist options
  • Save hhenrichsen/2c299c81058c94393e06dae1dbc5b1cf to your computer and use it in GitHub Desktop.
Save hhenrichsen/2c299c81058c94393e06dae1dbc5b1cf to your computer and use it in GitHub Desktop.
var isPalindrome = (str) =>
str.toLowerCase()
.split("").reduce((a, i) => a += (i.match(/^[A-Za-z0-9]/) ? i : ""), "") //Kill invalid characters.
.split("").reduce((a, i, idx, c) => a && i === c.pop(), true); //Check equivalency; Short circuit if needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment