Find why mapping products throws instead of producing labels.
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);