Palindrome Checker Javascript

Hi Guys

Can you perhaps tell me why my code is not working?

function stringWithAlphaNUmeric(str){
   return str.replace(/[^\W_]/gi, "");

function stringLowercased(str) {
   return str.toLowerCase();

const stringReversed = (str) => {
  let result = "";
  for (let i = str.length-1; i >= 0; i--) {
     result += str[i];
  return result;

function palindrome(str) {
    const cleanedUpStr = stringWithAlphaNUmeric(str);

  const lowercaseStr = stringLowercased(cleanedUpStr);
    const reversedStr = stringReversed(lowercaseStr);
    console.log(`Is "${lowercaseStr}" equals to "${reversedStr}"?`);

  return lowercaseStr == reversedStr;


Hi @ttinaapi88

Welcome to FCC.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you for the insights

In your solution, you are returning the reversed string not whether the string is a palindrome or not. Try something like:

return result === str;

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