← All tasksJavaScript · Junior

isPalindrome: palindrome check

Write a function isPalindrome(str) that checks whether a string reads the same both ways.

Ignore case, spaces and punctuation, and remember that letters may come from any alphabet: "А роза упала на лапу Азора" is a palindrome. An empty string counts as a palindrome too.

Tests (7)

  1. expect(isPalindrome("racecar")).toBe(true);
  2. expect(isPalindrome("hello")).toBe(false);
  3. expect(isPalindrome("A man, a plan, a canal: Panama")).toBe(true);
  4. expect(isPalindrome("А роза упала на лапу Азора")).toBe(true);
  5. expect(isPalindrome("12321")).toBe(true);
  6. expect(isPalindrome("ab")).toBe(false);
  7. expect(isPalindrome("")).toBe(true);