I have completed the Palindrome checker problem, but I keep getting an error message that reads TypeError: str.lowerCase is not a function. What is the issue with my code?
Your code so far
function palindrome(str) {
var reg = /[^\w_]/g;
var lowerCase = str.lowerCase().replace(reg, " ");
var rev = str.split("").reverse().join("")
if (rev === str) return true;
return false;
}
palindrome("eye");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0
Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker
Thank you, that corrected a lot of my coding, its still an error. Certain words such as _eye does not return true, when the problem is saying it should.
Well, that was not your only issue. That was one of many. I can’t give you a lot of help on this since it is one of the final projects for certification. My suggestion would be to use console logs to check and see if your regular expression is doing what you want it to do. You’ll probably want to do that in other places as well as the regular expression is not your only issue.
You declared lower here but then never access it again. I’m assuming you created it for some reason?
I’ll suggest this one more time, try using some console logs to make sure the value of the variables you are creating are what you want them to be.
Also, try testing with more examples. The tests are showing you which strings are being tested and what the function should return for each one. You should test these on your own to make sure they are doing what the tests want.