const solution = string => {
string = string.toLowerCase().replace(/[^a-z]/g, '');
const length = string.length;
for (let i = 0; i < Math.floor(length - 1 / 2); i++) {
if (string[i] != string[length - 1 - i]) {
return 'NO';
}
}
return 'YES';
};
const result = solution('found7, time: study; Yduts; emit, 7Dnuof');
console.log(result);
function solution(s) {
let answer = 'YES';
s = s.toLowerCase().replace(/[^a-z]/g, '');
console.log(s);
if (s.split('').reverse().join('') !== s) return 'NO';
return answer;
}
let str = 'found7, time: study; Yduts; emit, 7Dnuof';
console.log(solution(str));