Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!