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

154
Views
why isnt michael jordan matching in my regexp

my code is supposed to match all of the key names that contain the inputted string. however when i enter "o" it wont match jordanMichael but will match noahsinnott and bobross. does anyone know why? this also happens when i enter 0 as it only matches noah when harry styles also has a zero in his key. when matched with no string it also returns all the keys so i know it is defiantly running him through the test but for some reason he never passes.

var adressLog = {
  NoahSinnott07484743803: {
    firstName: "Noah",
    lastName: "Sinnott",
    number: 07484743803,
    adress: "st michaels house, church street, billinghay"
  },

  HarryStlyes08674563827: {
    firstName: "Harry",
    lastName: "Styles",
    number: 08674563827,
    adress: "23 Merry gold lane, new-york"
  },

  BobRoss67543456754: {
    firstName: "Bob",
    lastName: "Ross",
    number: 67543456754,
    adress: "93 Scrooby Rd, Bircotes, Doncaster DN11 8JN"
  },

  JordanMichael78675678765: {
    firstName: "Jordan",
    lastName: "Michael",
    number: 78675678765,
    adress: "2700 Point Dr, Highland Park, IL 60035"
  }
};

function match(str) {
  a = new RegExp(str, "ig");
  let matches = [];
  let length = Object.keys(adressLog).length;
  for (let p = 0; p < length; p++) {
    current = Object.keys(adressLog)[p];
    if (a.test(current) == true) {
      matches.push(current);
    }
  }
  console.log(matches);
}
match("o");

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!