Question:

Once this code is executed, what value will result hold?

let numbers = [1, 3, 5, 7, 9]
let result = numbers.reduce(0, +)

Correct answer: 25.

Explanation: The reduce method combines the integers in the numbers array into a single value by applying a function to each one. In our case, that's the + operator, which means "add all these numbers together", giving 25.

 


Keywords:

© 2017 QuizBucket.org