When I try and use this code it tells me:

“TypeError: together.reverse is not a function. (In ‘together.reverse()’, ‘together.reverse’ is undefined)”

I am obviously miss understanding something here, but even with research it’s just not clicking. Could someone explain why the code is wrong?

Here’s my code so far.

```
function palindrome(str) {
let newStr = str.toLowerCase().match(/[a-z0-9]/g);
let together = newStr.join('');
let backwards = together.reverse();
if (together === backwards) {
return true;
} else {
return false;
}
}
palindrome("eye");
```

```
**Your browser information:**
```

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15`

**Challenge:** Palindrome Checker

**Link to the challenge:**

I like to figure out what things I’m dealing with

```
function palindrome(str) {
let newStr = str.toLowerCase().match(/[a-z0-9]/g);
console.log(newStr);
let together = newStr.join('');
console.log(together);
let backwards = together.reverse();
if (together === backwards) {
return true;
} else {
return false;
}
}
palindrome("eye");
```

1 Like

Oh my goodness thank you so much!

It still took a minute but I think I understand now.

.reverse() would only work on an array, so I needed to do that before .join(’’).

I ended up with this:

function palindrome(str) {

let newStr = str.toLowerCase().match(/[a-z0-9]/g);

let together = newStr.join(’’);

let flip = newStr.reverse();

let backwards = flip.join(’’);

if (together === backwards) {

return true;

} else {

return false;

}

}

palindrome(“eye”);

I little wordy but it works!

Thank you again

Some logging statements and verifying what methods work on what types of things will get you far. Good work on the fix!

1 Like