JSFiddle - React, Tailwind, and code Playground
by krustnic
JavaScript
function isPoly(seq) {
seq = seq.replace(/\s|[0-9]*/g, '')
let i = 0
let j = seq.length - 1
while(i<j) {
if (seq[i] !== seq[j]) {
return false
}
i += 1
j -= 1
}
return true
}
console.log(isPoly('шалаш'))
console.log(isPoly('а123 роза упала на лапу азора'))
console.log(isPoly('азор'))