找出产品标签里的 bug

来自 类
Node 24 进阶 4分钟 找出 1处问题

找出映射商品时为何抛错,而没有生成标签。

JavaScript
class PriceList {
  constructor(currency) {
    this.currency = currency;
  }

  label(product) {
    return `${this.currency} ${product.price.toFixed(2)}`;
  }
}

const list = new PriceList('USD');
const products = [{ price: 8 }, { price: 12.5 }];
const labels = products.map(list.label);
console.log(labels);
在试验场中打开
报告错误