{}
run-icon
main.js
function fulfilledOrdersBeforeFailure(orders, stock) { let fulfilled = 0; for (const order of orders) { let possible = true; for (const flavor of order) { if (!stock[flavor] || stock[flavor] <= 0) { possible = false; break; } stock[flavor]--; } if (!possible) { return fulfilled; } fulfilled++; } return fulfilled; }
Output