Check for Palindromes code

Check for Palindromes code
0

#1

Tell us what’s happening:
My code is basically the same as the basic solution in get a hint. Can someone please let me know why this isn’t working? What am I missing?

Thank you, appreciate it a lot!

Your code so far

function palindrome(str) {
  var modifiedString = str.replace(/\W/g, "").toLowerCase.split('').reverse().join('');
  var lowerCaseString = str.replace(/\W/g, "").toLowerCase;
  if (modifiedString === lowerCaseString) {
    return true;
  } else {
  return false;
  }
}


palindrome("eye");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:


#2

You have two problems.

One is just a straight up error stopping your code from running. Look at your toLowerCase method closely to see what might be wrong with it.

The second issue is that you are not dealing with underscore characters properly. Once you fix your error, check which test cases you are still failing and try to amend your regex to get it passing.

Happy coding!


#4

Thanks a lot!
I fixed the errors you mentioned and it worked. :grin: