X275: Recursion Programming Exercise: Check Palindrome
Write a recursive function named checkPalindrome
that takes a
string as input, and returns true if the string is a palindrome and false
if it is not a palindrome. A string is a palindrome if it reads the same
forwards or backwards.
Recall that str.charAt(a)
will return the character
at position a
in str
. str.substring(a)
will return the substring of
str
from position a
to the end of str
, while str.substring(a, b)
will return the substring of str
starting at position a
and continuing
to (but not including) the character at position b
.
Examples:
checkPalindrome("madam") -> true
Your Answer:
Feedback
Your feedback will appear here when you check your answer.