Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
420 B
1
Indexable
Never
function palindrome(str) {
  let palindromedStr = [];
  str = str.toLowerCase();
  const regex = /[a-z]|\d/g
  str = str.match(regex).join("")
  for(let i=1;i<str.length+1;i++){
    if(str[i-1] === str[str.length-i]){
      palindromedStr.push(str[str.length-i])
    }
  }
  if(palindromedStr.join("") === str)
  {
    return true;
  }else{
    return false;
  }
}


palindrome("1 eye for of 1 eye.")