Answers for "A Chain adding function"

0

A Chain adding function

function add(n){
  // Let the currying begin!
  var currentSum = n;
  
  function addF(b) {
    currentSum += b;
    return addF;
  }
  
  addF.toString = function() {
    return currentSum;
  };
  
  return addF;
  
}
Posted by: Guest on May-07-2021

Browse Popular Code Answers by Language