Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
210
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( obj ) {
  11.         if (obj == addition) {
  12.             consoleLog( result );
  13.         } else {
  14.             consoleLog( obj );
  15.         }
  16.     };
  17.    
  18.     return addition;
  19. }());
  20.  
  21. console.log( add( 1 )( 2 )( 3 ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement