Palindrome

Write a function that receives a text and returns true or false (Boolean) depending on whether or not they are palindromes.

  • A palindrome is a word or expression that's the same whether read from left to right or from right to left.
  • Spaces, punctuation marks and accent marks aren't taken into account.
  • Example: Ana lleva al oso la avellana.
solution.js
1function isPalindrome(text) {
2 text = text.toLowerCase().replace(/[^a-z0-9]/g, "");
3
4 return text === text.split("").reverse().join("");
5}
6
7const exampleText = "Ana lleva al oso la avellana.";
8
9const result = isPalindrome(exampleText);
10console.log(result);