Created
June 29, 2017 13:38
-
-
Save daniellizik/fc185fd14883fa21669246cb9db0f7b1 to your computer and use it in GitHub Desktop.
js functional palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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