DEV Community

silas gebhart
silas gebhart

Posted on

reduce() iterator

Hello! I forgot to post a lot of my progress so far, however we have made progress. I have been starting to record myself as I go along. I heard that if you are able to teach someone else, then you are comprehending the material. Thus, I might post on here!

I have been going over array iteration! Just finished with the reduce() iterator. Below you can see the work I did.

// Code your solution here
const batteryBatches = [4, 5, 3, 4, 4, 6, 5];

function batteryReducer(totalBatteries, currentBatch) {
return totalBatteries + currentBatch;
}

const totalBatteries = batteryBatches.reduce(batteryReducer, 0);

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay