找出运费检查里的 bug

来自 可执行规格
Node 24 进阶 5分钟 找出 2处问题

找出这些生成检查为何无法独立规定运费边界。

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

function shippingFeeCents(subtotalCents) {
  return subtotalCents >= 5000 ? 0 : 500;
}

const sampledSubtotals = [6000, 7000];
for (const subtotalCents of sampledSubtotals) {
  const expected = subtotalCents >= 5000 ? 0 : 500;
  assert.equal(shippingFeeCents(subtotalCents), expected);
}
在试验场中打开
报告错误