Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Is Palindrome

Data Structures, Operators & Stringsmedium

Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 128: Working With Strings - Part 1

Implement `isPalindrome(str)` that returns `true` if `str` reads the same forwards and backwards (case-insensitive, ignore non-alphanumeric characters).

Sample tests

Input: isPalindrome("racecar")
Output: true
Input: isPalindrome("hello")
Output: false
Input: isPalindrome("A man a plan a canal Panama")
Output: true

+ 2 hidden tests run on Submit.

Hints

Common pitfalls
  • Skipping case normalization misjudges mixed-case palindromes.

Learning resources

  • MDN: String.prototype.replace
Approach & explanation (try first)

Comparing the lowercased string to its reverse checks for a palindrome regardless of case.

Loading...
⌘/Ctrl + Enter

Run your code to see results.