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.
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);