I don't get it, I did something almost exactly the same but not sure why it won't pass.
function invalidTransactions(transactions) { const review = {}; const invalidTransactions = []; for (const t of transactions) { const [name, time, , city] = t.split(','); if (name in review) review[name].push({ time, city }); else review[name] = [{ time, city }]; } for (const transaction of transactions) { const [name, time, amount, city] = transaction.split(','); const prevTransactions = review[name]; if (amount > 1000) { invalidTransactions.push(transaction); } for (const prevTransaction of prevTransactions) { const { time: prevTime, city: prevCity } = prevTransaction; if (city !== prevCity && Math.abs(time - prevTime) <= 60) { invalidTransactions.push(transaction); } } } return Array.from(invalidTransactions); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't get it, I did something almost exactly the same but not sure why it won't pass.