function palindrome(str) {
// Good luck!
var pattern = new RegExp("[`~!@#$^&*%()=|{}':;',\\[\\].<>/?~!@#¥……&*()&;|{}【】‘;:”“'。,、? _-]");
var rs = "";
for (var i = 0; i < str.length; i++) {
rs = rs+str.substr(i, 1).replace(pattern, '');
}
var clearString = rs.toLowerCase();
console.log(clearString);
var splitArray = clearString.split("");
var reverseArray = splitArray.reverse();
var reverString = reverseArray.join("");
var isTrue = true;
if(reverString != clearString)
{
isTrue = false;
}
console.log(isTrue);
return isTrue;
}
palindrome(“not a palindrome”);