Skip to content
dreamcode
dreamcode
Lesson
Practice · Array reduce
  1. Predict
  2. Arrange
  3. Fill in
+20 XP on finish
PREDICT · READ BEFORE YOU WRITE

What does this program print?

Trace the program the way the computer would, then make your call before running anything.

const starMag = [
  { name: 'Vega', mag: 0 },
  { name: 'Polaris', mag: 2 }
];
const result = starMag.reduce((acc, star) => {
  return acc + star.mag;
}, 10);
console.log(result);