Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adeleke5140
Created September 16, 2022 14:10
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 adeleke5140/96814aef7a3c27fe0173705475ccccfc to your computer and use it in GitHub Desktop.
Save adeleke5140/96814aef7a3c27fe0173705475ccccfc to your computer and use it in GitHub Desktop.
Check if a string is a palindrome with recursion
function isPalindrome(input){
if(input.length == 0 || input.length ==1 ){
return true
}
if(input.charAt(0) == input.charAt(input.length -1 )){
return isPalindrome(input.substring(1, input.length -1)
}
return false;
}
isPalindrome('kayak')
//true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment