function palindrome(str) {
let arrSplit = str.split("");
let arrReverse = arrSplit.reverse()
let arrJoin = arrReverse.join("")
let remPunc = /[\W_]/g
let correctedStr = arrJoin.replace(remPunc, '')
let rightOne = correctedStr.toLowerCase();
if (str === rightOne){
return true
}else{
return false;
}
}
palindrome("eye");
ok. so do I have to name a new string and compare with rightOne?
and moreover, I used /[\W_]/g to remove all non-alphanumeric characters
ok thank you very much
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.