Reduce Polyfill Javascript

// Array.reduce((accumulator, current, index, originalArray) => {}, initialValue)

Array.prototype.myReduce = function(cb, initialValue) {
	let accumulator = initialValue;

	for (let i = 0 ; i < this.length ; i++ ) {
		// handling the condition where initial value is not given
		accumulator = accumulator ? cb(accumulator, this[i], i, this) : this[i];
	}

	return accumulator;
};

Reduce Javascript