How to begin solving the palindromes javascript?

Hello Everyone,

When removing characters…say special characters. How can I use the regular expression method to do this task? I know what else methods to use, but I’m confused how I remove special characters using the regular expression.

I recommend using replace(). For trying out your use of regular expression tokens, regex101 is very handy.

1 Like

Okay. I think I’ll just use replace. I’ve spent way to much time on this algorithm.

I’ve been working on this for 2 hours now with no progress. I really don’t know what to do. Here is what I have. I hope you guys can help. I really don’t want to look at the solution.

function palindrome(str) {

var toLowerCaseString = str.toLowerCase();

return toLowerCaseString;

}

palindrome(“EYE!”);

I don’t know how to use the replace() function to get rid of the special characters. Any ideas on what I can do?

I didn’t want to, but I found a couple answers on the Freecode camp forums. I did, however, do a Google search and found this below.

https://www.w3schools.com/jsref/jsref_obj_regexp.asp

I’m starting to see these basic methods are really powerful. You can do allot with very little code and without doing loops. Coming from a Java background this is pretty cool.

Thank you randelldawson! Time to get back to work.