Help needed regarding this problem's logic

function palindrome(str) {
// Good luck!

str=str.toLowerCase();

var arr=str.split(’’);

arr=arr.filter(function(ch){
return /[a-z]/.test(ch);
});

arr=arr.reverse();

arr=arr.join(’’);

if(str===arr) return true;

else return false;

// return str.toLowerCase().split(’’).filter(function(ch){
// return /[a-z]/.test(ch);
// }).reverse().join()===str;
}

palindrome("_eye");

Can someone pls help me in finding the mistake in this approach?

Thanks in advance

This:

’’

is not an empty string. Those are:

'' ""
testVar = _eye
arr = eye
str = _eye

testVar = race car
arr = racecar
str = race car

testVar = A man, a plan, a canal. Panama
arr = amanaplanacanalpanama
str = a man, a plan, a canal. panama

get rid of space and symbol in your str

Hi…yea…it’s already taken care of, using regexp…thanks

Hi…we can use either single quotes or double quotes to store string…right?

The answer to your question is Yes.