I am following full stack curriculum and regex lesson is after 2 chapters. I am unable to form a logic how that how I can remove all those symbols and spaces. Please guide me.
PS- I thought I can list all symbols and spaces then split it into array. Then use a for loop and filter, but I got some error and I am heavily confused now. Please help me.
yes it is a limiting approach but I think after I learn regex (after 1 more chapter ) then it won’t be limiting. I think this project is given before regex to test our loop, function, callbacks and some methods knowledge.
I didn’t realize that basic regular expressions were not introduced before the Palindrome Checker in the Certified Full Stack Developer curriculum (they are in the legacy JavaScript curriculum).
Since you aren’t prepared to use regular expressions yet, you could take the opposite approach to what you are currently trying to do. You don’t know what special characters the test string might include, but you do know what characters your string is allowed to accept – all alphanumeric characters, right? So maybe check to see if the original string contains an alphanumeric character and if it does, keep it. Skip everything else.
The loop problem is that the ‘return false’ and ‘return true’ from inside the loop ends the loop at the first character checked. If a match is found, the function should ‘return false’, but if no match is found, it should only return ‘true’ after checking all characters.
And also ’ .reverse()’ modifies the array in place, which might cause side effects.
It’s better to create a copy before reversing.
Instead of looping through ‘symbArr’, you can use ‘symbArr.includes(char)’, which is cleaner and more efficient.