JSFiddle - React, Tailwind, and code Playground
JavaScript
// implemnting array reduce
function reduce(fn, initial) {
const arr = this;
var acc = initial;
this.forEach((ar, index) => {
acc = fn.call(this, acc, ar, index);
})
return value;
}