JavaScript Algorithms and Data Structures Projects - Palindrome Checker

I’ve been looking this over a while now, so figured I’d finally reach out for help… The error I’m receiving says: TypeError: cleanString.split is not a function

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
function palindrome(str) {
let cleanString = str.replace(/\W+|_/g, "").toLowerCase;
let reversedString = cleanString.split("").reverse().join("");
//console.log(cleanString, reversedString)
if (cleanString != reversedString) {
  return false;
}
return true;
}

let result = palindrome("racecar");
  **Your browser information:**

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

Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Link to the challenge:

That’s usually an indication that you are trying to call a method on some data type that does not support that method.

function palindrome(str) {
  // What does str.toLowerCase do? How do you call a function?
  let cleanString = str.replace(/\W+|_/g, "").toLowerCase;
  let reversedString = cleanString.split("").reverse().join("");
  //console.log(cleanString, reversedString)

  // Note that you can just return the result of a boolean test
  // that is much more idiomatic
  if (cleanString != reversedString) {
    return false;
  }
  return true;
}

let result = palindrome("racecar");
1 Like

¡Hola! aun soy nuevo en esto, pero justo hace pocos dias resolvi este proyecto con una solución similar y me parece que al método .toLowerCase( ) le falta la zona de parametros. saludos.