Higher Order Functions

reduce Combines Values

reduce Combines Values

reduce turns an array into one accumulated result. The callback receives the current accumulated value and the current item.

An explicit starting value keeps the result predictable, including when the array is empty. For totals, that starting value is usually 0.

Your task: Use reduce to create totalMinutes from lessonMinutes. Combine all durations into one number.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

reduce Combines Values

reduce turns an array into one accumulated result. The callback receives the current accumulated value and the current item.

An explicit starting value keeps the result predictable, including when the array is empty. For totals, that starting value is usually 0.

Your task: Use reduce to create totalMinutes from lessonMinutes. Combine all durations into one number.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.