Palindrome Checker
15 minIntermediateAlgorithms
A palindrome reads the same in both directions: kayak, racecar, 12321. For sentences we ignore everything except letters and digits, so "A man, a plan, a canal: Panama!" counts. The starter only works for lowercase single words.
isPalindrome("kayak") // true
isPalindrome("Kayak") // true
isPalindrome("A man, a plan, a canal: Panama!") // true
isPalindrome("No 'x' in Nixon") // true
isPalindrome("hello") // false
isPalindrome("123 45") // false
isPalindrome("") // true (nothing to mismatch)Examples
Constraints
- Compare only the letters
a–zand digits0–9, case-insensitively. Everything else is ignored. - An empty string (or one with only punctuation) counts as a palindrome.
- Always return a real boolean:
trueorfalse.
Fix isPalindrome(text) so it returns true when text reads the same forwards and backwards ignoring case, spaces and punctuation, and false otherwise.
Checks
- Recognises simple words
- Ignores case, spaces and punctuation
- Handles digits and edge cases
Preview
Console output from your code appears here.