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

103
Views
Evaluar y dar la salida en 2 matrices

const orderList = [["paul", "enter"],["jenny", "exit"],["paul", "exit"],["phil", "enter"],["shriya", "exit"],["shriya", "enter"],["shriya", "exit"],["paul", "enter"]["phil", "exit"],["Dan", "exit"],["Dan", "enter"]] Siguiendo el orden anterior, evalúe y proporcione la salida en 2 matrices, una para entrada incorrecta y otra para salida incorrecta. El orden es importante. Ejemplo: Paul ha entrado y salido, lo cual es correcto. De nuevo ha entrado pero no salido. Entonces él viene en una matriz de salida incorrecta.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si lo adiviné correctamente, entonces esto es lo que estás buscando.

 function check(orderList) { eventCount = {}; for(let i = 0; i < orderList.length; i++){ if(orderList[i]){ let person = orderList[i][0]; console.log(person, "--> ",orderList[i][1] ); if(!eventCount.hasOwnProperty(person)){ eventCount[person] = 0; } if(orderList[i][1] === "enter"){ eventCount[person] = eventCount[person]+1; } else { eventCount[person] = eventCount[person]-1; } } } let right = []; let wrong = []; for (const person in eventCount) { if(eventCount[person] === 0) { right.push(person); }else { wrong.push(person); } } console.log("right -> ", right); console.log("wrong -> ", wrong); } const orderList = [["paul", "enter"], ["jenny", "exit"], ["paul", "exit"], ["phil", "enter"], ["shriya", "exit"], ["shriya", "enter"], ["shriya", "exit"], ["paul", "enter"],["phil", "exit"],["Dan", "exit"],["Dan", "enter"]]; check(orderList);

about 4 years ago · Juan Pablo Isaza Report
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!