Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
JavaScript Anagram Checker with one string

I am trying to solve the JS Anagram checker, I have a string first I need to separate the words and then need to check the anagrams the words may have spaces, punctuations or special character. Below is my code

module.exports = function (str) {
  let mystring = str.toLowerCase()
  let string1 = mystring.replace(/[.\/#!$%\^&\*;":{}=\-_`~()]/g, "");
  let rsstring1 = string1.replace( /\s/g, '')
  const words = rsstring1.split(",");
  let str1 = words[0];
  let str2 = words[1];
const sorted1 = str1.split("").sort().join("");
const sorted2 = str2.split("").sort().join("");
  
   if(sorted1 === sorted2){
    return true;
   } else { 
    return false;;
   }
}

The issue I am getting is Cannot read properties of undefined (reading 'split')

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda