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)