Data Structures Projects

what is missing to complete this exercise? Thanks


function palindrome(str) {
  str = str.toLowerCase().replace(/[\W_]/g, '');
  for (var i = 0, len = str.length - 1; i <len/2; i ++) {
    if (str [len - 1]) {
      return true;
    }
  }

return false;
}

palindrome("eye");
  **Your browser information:**

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

Challenge: Palindrome Checker

Link to the challenge:

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 (').

What are you checking with this?

if (str [len-i]) { return true; } et cetera How can I turn into the same case (Lower or uppercase)?

I don’t understand what you want str [len-i] to do though.

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