Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created June 30, 2020 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/159da201c4df7d252b62157dce25ceea to your computer and use it in GitHub Desktop.
Save BetterProgramming/159da201c4df7d252b62157dce25ceea to your computer and use it in GitHub Desktop.
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