Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. Array.prototype.myNewReducer = function (callback, accumulator){
  2. const length = this.length;
  3. let i = -1;
  4.  
  5. if( !accumulator && length > 0){
  6. accumulator = this[++i];
  7. }
  8.  
  9. while(++i < length){
  10. accumulator = callback(accumulator, this[i], i, this);
  11. }
  12.  
  13. return accumulator;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement