Problem 10

Palindrome Recursion Challenge

Given a string, determine whether it is a palindrome. A palindrome reads the same forward and backward. The comparison should be case-insensitive and should ignore spaces.

Function Signature

palindrome(string)

Parameters

  • string — a string that may contain letters, spaces, and mixed casing.

Output

Return true if the string is a palindrome, or false otherwise.

Constraints

  • The function must use recursion.
  • Do not use Array.prototype.reverse.
  • The comparison is case-insensitive.
  • Spaces should be ignored when checking.
  • The function should accept exactly one argument.

Examples

palindrome('racecar')  → true
palindrome('Rotor')    → true
palindrome('hello')    → false
palindrome('o')        → true
palindrome('hi')       → false

Edge Cases

  • A single character is always a palindrome.
  • Strings with mixed casing like 'Rotor' should return true.
  • Strings with spaces like 'sAip puaki v iKaup Pias' should return true (spaces ignored).