Algorithm palindrome checker

without the guide help i can't do it on my own. What's missing here? Thanks to whom, patiently, answer me back.

function palindrome(str) {
if (str) {

return true;
return false;
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Palindrome Checker

Link to the challenge:

What do you want this line to do?

I’ve written using the three backsticks required but something 's went wrong.

if  (str) {
return true;
return false;
palindrome ("eye");

I can see the code you have written. But I don’t understand what you thing if (str) does. It doesn’t seem to be related to checking for a palindrome at all, so I’m trying to understand what you are thinking.

hi, you didnt specify what the if statement should do, you just return true,
think about it and retry it cheers

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

I would suggest you start by just telling us the steps you would take to determine if a string is a palindrome. Don’t even worry about writing any code yet. Just tell us in plain English what you would do to figure it out.

1 Like

Hello, there’ s no help guide in the last 5 exercises of JavaScript Algorithm …

The projects? That is on purpose. You shouldn’t copy somebody else’s project and submit it as your own.

You can ask questions here on the forum and we can help you work on the projects, but the code has to be your own.

im sure u learn the RegExp section. use what u learned in that section. palindrome checker is checking the str arguments same or not with reversed str. try to using regexp section to fulfill this project

Did everyone else use a bunch of regexes for this one? I used just a single quick regex check line in my solution:


Did I miss something that was a lot easier than what I did? (strip down to lower case alphanums, then just go through the first half of the sentence, checking against the back half as I went).

There are a lot of ways to code a solution for this problem. Your solution is fine, but you are introducing a loop, which is not necessary if you use a functional approach. For instance, it is possible to solve this problem with just one return statement. Granted, there are just a few methods being used in that return statement, but a lot of people would consider the fact that you didn’t need to add a loop worth it.

Personally, I would probably use two lines of code to solve this problem because you can remove some repetitive method calls by cleaning up the input string first. I would suggest you you try to solve this using a functional approach and see if you can get it down to two lines of code as well (or even one if you prefer).

Two lines would be a big change. I’ll have to take a look! (probably after I finish the rest of the projects first).

EDIT: By functional do you mean recursive? I definitely have a very limited grasp of recursion so far (used it successfully in one of the algos, but otherwise only in the actual lessons on it). If not, can you explain what functional means in this case? I did avoid modifying any passed values, which I thought was the definition. Thank you for the help!

This is another reason why many people would prefer a functional approach for this solution, because two lines of code is simpler. Also, using functional methods often leads to better readability because the method names usually tell you what the method is doing.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.