Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Array.prototype.myNewReducer = function (callback, accumulator){
- const length = this.length;
- let i = -1;
- if( !accumulator && length > 0){
- accumulator = this[++i];
- }
- while(++i < length){
- accumulator = callback(accumulator, this[i], i, this);
- }
- return accumulator;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement