JSFiddle - React, Tailwind, and code Playground

by Jagrati Tomar

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;
}