gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
getTotalCost(): number { let totalCost = 0; for (let item of this._items) { totalCost +=…
- User
getTotalCost(): number { let totalCost = 0; for (let item of this._items) { totalCost += item.price; } return totalCost; }
Замеени данный код, используя Метод reduce() typescript
- Assistant
getTotalCost(): number { return this._items.reduce((acc, item) => acc + item.price, 0); }