Skip to content

Instantly share code, notes, and snippets.

@daniellizik
Created June 29, 2017 13:38
Show Gist options
  • Save daniellizik/fc185fd14883fa21669246cb9db0f7b1 to your computer and use it in GitHub Desktop.
Save daniellizik/fc185fd14883fa21669246cb9db0f7b1 to your computer and use it in GitHub Desktop.
js functional palindrome
const pal = (s) => s
.split('')
.reduce((acc, c, head, arr) => Object.assign({}, acc, {
tail: acc.tail - 1,
result: (acc.result === false || arr[head] !== arr[acc.tail]) ? false : true
}), {result: null, tail: s.length - 1})
.result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment