Created
January 14, 2015 18:29
-
-
Save smoothness/4fdefb72688b75a6492f to your computer and use it in GitHub Desktop.
isPalindrome recursive function from Secrets of the JavaScript Ninja
This file contains 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
function isPalindrome(text) { | |
if (text.length <= 1) return true; | |
if (text.charAt(0) != text.charAt(text.length - 1)) return false; | |
return isPalindrome(text.substr(1, text.length - 2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment