找出库存检查里的 bug

来自 示例与反例
Node 24 进阶 5分钟 找出 2处问题

找出这些生成检查为何无法确定请求中的库存规则。

JavaScript
import assert from "node:assert/strict";

const cases = [
  { input: { stock: 4, reorderAt: 8, discontinued: false } },
  { input: { stock: 3, reorderAt: 8, discontinued: false } },
  { input: { stock: 2, reorderAt: 8, discontinued: false } },
];

for (const example of cases) {
  const expected = example.input.stock < 10 ? "reorder" : "hold";
  assert.equal(reorderDecision(example.input), expected);
}
在试验场中打开
报告错误