Implenting Array.reduce() Method from scratch
// normal
arr.reduce(callbackfn, initialValue);
// callback function with parameters
// initialValue maybe 0 or whatever you can give
arr.reduce((previousValue, currentValue, currentIndex, array) => {
const nextValue = previousValue + currentValue;
...
sagyr.hashnode.dev1 min read