Mallik's Palindrome

function palindrome (string){
  let num = Math.ceil(string.length%2)
  for(let i=0;i<num;i++){ 
    if(string[i]!==string[string.length-(i+1)]){
      return false;
    }else{
      return true;
    }
}
}

You removed the stuff you had in there about converting the string to lowercase and getting rid of all non-alphanumeric characters. I’d put that back in.

Think about your for loop. You are doing an if/else statement in there and both of those statements return. How many times is the for statement going to loop in this case?

string.length%2

Can you explain what you are trying to do here?

Personally, I think a for loop might not be the best, or at least clearest way to go here. If you think about what you are trying to do, starting at either end of the string and working your way toward the middle, I think a while loop works just as well and is perhaps easier to comprehend. It might take a few more lines of code but you shouldn’t always sacrifice clarity for brevity.

I moved your question to its own topic because you were asking a question related to your own code for a challenge and were not answering the OP of the other thread. It is always best to create your own thread for you specific question(s). Also, it is advisable to use the Ask for Help button on the challenge, so it auto-populates with your current code and the challenge url.

Thank you.