Created
June 30, 2020 14:54
-
-
Save BetterProgramming/159da201c4df7d252b62157dce25ceea to your computer and use it in GitHub Desktop.
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(str) { | |
// base case: reaching midpoint, or empty str | |
if (str.length <= 1) { | |
return true | |
} | |
if (str[0] !== str[str.length - 1]) { | |
return false | |
} else { | |
return isPalindrome(str.substring(1, str.length - 1)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment