JavaScript Algorithms and Data Structures Projects - Palindrome Checker

I have a feeling im missing something in my regex, but that im pretty close can anyone confirm? :]
Your code so far

function palindrome(str) {
  let final = []
  let string = str.toLowerCase()
  let filter = string.split(/\A+\s+/g)
  for(let i = filter.length - 1; i>= 0; i--){
    if(filter.length !== final.length){
      return false
    } else {
      return true
  return true;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/107.0.1418.56

Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Link to the challenge:

hi there, I’m not sure I understand your algorithm.
What is the pattern supposed to match?

anything that isnt an alphanumeric number including spaces, and underscores. I know i have to add the underscore symbol as well since the \A doesnt include _

I guess I’m confused because your pattern starts with \A+ which matches the character A but nothing else.
Maybe you wanted to use \W actually?
Here’s a regex cheat sheet that should help

1 Like

I did mean \W haha dang it, thank you ill look over the regex sheet

1 Like

Note that \W is the opposite of \w. The \W shortcut means a non-alphanumeric character (e.g. NOT A-Z, a-z, 1-9 or underscore).

EDIT: Sorry, misread your post. As you were.

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