Hello. I would welcome any feed back on palindrome checker project. It’s simple, but I’d would like to know if my solution would be acceptable in real work environment. Maybe the code is clean enough (like the function train xD) or maybe there is some rare example that would fail test. Thank you in advance for every advice.
Here’s my code:
function palindrome(str) {
let temp = str.replace(/\W|_/g, "").toLowerCase();
let reversed = temp.split("").reverse().join("");
return temp === reversed;
}
I think there is one big change you can make that would simplify this greatly. What are the first two let statements doing? What type of value do they hold? How would you normally compare those types of values to see if they are equal?