Hi! after browsing forum i found what i have to change, and Icame with solution:
function palindrome(str) {
str = str.replace(/\W+/g, “”).replace(/_/g, “”).toLowerCase();
var str1 = str.split("").reverse().join("");
if (str == str1){
return true;
}
return false;
}
BUT I don’t know why if i make: str = str.replace(/[0-9]/g,"").replace(/\W+/g, “”).replace(/_/g, “”).toLowerCase(); code dosen’t work, becouse with “1 eye for of 1 eye.” I’m geting true, not false. From what i understood i first it replace all numbers, then characters and then _ and after it make it all lower case. Why it isn’t working, if only it’s just longer?