课程: Level Up: JavaScript

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Coffee calculations

Coffee calculations

(upbeat music) - The array reduce method runs a function once for every item in an array and returns a single value. The reduce function is a function that you provide that takes an accumulator value and a current value. The accumulator value is the combined total of all previous callback function runs and the current volume is the current value in the array that we're executing this function on. In this challenge, you'll be using the array reduce function to calculate the total bill from a trip to the coffee shop with your friends. Each person has ordered some number of coffees and you offer to pay the entire bill. Given an array of integers where each value is greater than zero, calculate the total price of all coffees. Each coffee costs $1.25. You should return your answer in the following format. The total bill is followed by the total. You should use template literals for your return value. Template literals…

内容