Drill

ProblemsJavaScript › inventory

When to reorder a part

easyinventoryJavaScript

Purchasing wants the stock level at which a part should be reordered, so it arrives before the shelf runs dry.

reorderPoint(dailyUse: int, leadDays: int, safety: int) → int

Solve it in the editor →

Where you start

function reorderPoint(dailyUse, leadDays, safety) {
  
}

Worked examples

CallResult
reorderPoint(10, 3, 5)35
reorderPoint(0, 7, 20)20
reorderPoint(12, 0, 0)0
reorderPoint(-5, 3, 10)10

Hint

dailyUse × leadDays + safety, with each input floored at zero first.

Reference solution in JavaScript
function reorderPoint(dailyUse, leadDays, safety) {
  const d = Math.max(0, dailyUse), l = Math.max(0, leadDays), s = Math.max(0, safety);
  return d * l + s;
}

The same problem in another language

More inventory problems in JavaScript