What decisions does the specified inventory rule print?

from Examples and counterexamples
Node 24 intermediate 3 min

What decisions does the specified inventory rule print?

JavaScript
function reorderDecision({ stock, reorderAt, discontinued }) {
  return !discontinued && stock <= reorderAt ? "reorder" : "hold";
}

const inputs = [
  { stock: 8, reorderAt: 8, discontinued: false },
  { stock: 8, reorderAt: 5, discontinued: false },
  { stock: 0, reorderAt: 8, discontinued: true },
];

console.log(inputs.map(reorderDecision).join(", "));
Open in playground
Report an error