Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var add = (function() {
  2.     var consoleLog = console.log,
  3.         result = 0;
  4.    
  5.     function addition( n ) {
  6.         result += n;
  7.         return addition;
  8.     }
  9.    
  10.     console.log = function() {
  11.         for (var i in arguments) {
  12.             if (arguments[ i ] == addition) {
  13.                 arguments[ i ] = result;
  14.             }
  15.         }
  16.        
  17.         consoleLog.apply(this, arguments);
  18.     };
  19.    
  20.     return addition;
  21. }());
  22.  
  23. console.log( add( 1 )( 2 )( 3 ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement