📜  const calculateTotalImperative = (items, tax) => { let result = 0; for (const item of items) { const { price, taxable } = item; if (taxable) { result += price * Math.abs(tax); } 结果 += 价格; } 返回结果; }; - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:24.584000             🧑  作者: Mango

代码示例1
const calculateTotalImperative = (items, tax) => {
  let result = 0;
  for (const item of items) {
    const { price, taxable } = item;
    if (taxable) {
      result += price * Math.abs(tax);
    }
    result += price;
  }
  return result;
};