← 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.
Ctrl+Enter runs the tests. Tab indents; to leave the editor with the keyboard, press Esc and then Tab. Your code is saved in this browser.
Tests (7)
expect(isPalindrome("racecar")).toBe(true);
expect(isPalindrome("hello")).toBe(false);
expect(isPalindrome("A man, a plan, a canal: Panama")).toBe(true);
expect(isPalindrome("А роза упала на лапу Азора")).toBe(true);
expect(isPalindrome("12321")).toBe(true);
expect(isPalindrome("ab")).toBe(false);
expect(isPalindrome("")).toBe(true);