Skip to content

Instantly share code, notes, and snippets.

@aykutyaman
Last active January 21, 2019 13:51
Show Gist options
  • Save aykutyaman/5eb82000277ea74b2a89729ec1cb0ce6 to your computer and use it in GitHub Desktop.
Save aykutyaman/5eb82000277ea74b2a89729ec1cb0ce6 to your computer and use it in GitHub Desktop.
Recursive palindrome
// it works only with strings
const isPalindrome = ([head, ...tail]) => {
if (tail.length === 0) return true
if (head !== tail[tail.length - 1]) return false
return isPalindrome(tail.slice(0, tail.length - 1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment