
// function Change() {
//   this.memo = {};
// }
//
// Change.prototype.changePossibilitiesTopDown = function(amountLeft, denominations, currentIndex) {
//   currentIndex = (typeof currentIndex !== 'undefined') ? currentIndex : 0;
//
//   var memoKey = [amountLeft, currentIndex].join(', ');
//   // console.log(memoKey);
//
//   if (this.memo.hasOwnProperty(memoKey)) {
//     console.log('grabbing memo [' +memoKey+ ']');
//     return this.memo[memoKey];
//   }
//
//   // BASE CASES:
//   if (amountLeft === 0) return 1;
//
//   // overshoot amountLeft
//   if (amountLeft < 0) return 0;
//
//   // out of denominations
//   if (currentIndex === denominations.length) return 0;
//
//   console.log('Checking ways to make ' +amountLeft+ ' with [' +denominations.slice(currentIndex).join(', ')+ ']');
//
//   var currentCoin = denominations[currentIndex];
//
//   var numPossibilities = 0;
//
//   while (amountLeft >= 0) {
//     numPossibilities += this.changePossibilitiesTopDown(amountLeft, denominations, currentIndex+1)
//     amountLeft -= currentCoin;
//   }
//
//   this.memo[memoKey] = numPossibilities;
//   return numPossibilities;
// };
//
// new Change().changePossibilitiesTopDown(4, [1, 2, 3]);

function changePossibilitiesBottomUp(amount, denominations) {
  var waysOfDoingNCents = [];

  for (var i=0; i<=amount; i++) {
    // initialize arrays of 0s
    waysOfDoingNCents[i] = 0;
  }
  waysOfDoingNCents[0] = 1;

  denominations.forEach( function(coin) {
    for (var higherAmount=coin; higherAmount<=amount; higherAmount++) {
      var higherAmountRemainder = higherAmount - coin;
      waysOfDoingNCents[higherAmount] += waysOfDoingNCents[higherAmountRemainder];
      console.log(waysOfDoingNCents);
      console.log(coin);
    }
    console.log("---");
  });

  console.log(waysOfDoingNCents[amount]);
  return waysOfDoingNCents[amount];
}

// var results = changePossibilitiesBottomUp(5, [1, 3, 5]);
var results = changePossibilitiesBottomUp(4, [1, 2, 3]);
// console.log(results);

@@ -1,12 +1,9 @@
 %0A
-// 
 function
@@ -7,2002 +7,23 @@
 ion 
-Change() %7B%0A//   this.memo = %7B%7D;%0A// %7D%0A//%0A// Change.prototype.changePossibilitiesTopDown = function(amountLeft, denominations, currentIndex) %7B%0A//   currentIndex = (typeof currentIndex !== 'undefined') ? currentIndex : 0;%0A//%0A//   var memoKey = %5BamountLeft, currentIndex%5D.join(', ');%0A//   // console.log(memoKey);%0A//%0A//   if (this.memo.hasOwnProperty(memoKey)) %7B%0A//     console.log('grabbing memo %5B' +memoKey+ '%5D');%0A//     return this.memo%5BmemoKey%5D;%0A//   %7D%0A//%0A//   // BASE CASES:%0A//   if (amountLeft === 0) return 1;%0A//%0A//   // overshoot amountLeft%0A//   if (amountLeft %3C 0) return 0;%0A//%0A//   // out of denominations%0A//   if (currentIndex === denominations.length) return 0;%0A//%0A//   console.log('Checking ways to make ' +amountLeft+ ' with %5B' +denominations.slice(currentIndex).join(', ')+ '%5D');%0A//%0A//   var currentCoin = denominations%5BcurrentIndex%5D;%0A//%0A//   var numPossibilities = 0;%0A//%0A//   while (amountLeft %3E= 0) %7B%0A//     numPossibilities += this.changePossibilitiesTopDown(amountLeft, denominations, currentIndex+1)%0A//     amountLeft -= currentCoin;%0A//   %7D%0A//%0A//   this.memo%5BmemoKey%5D = numPossibilities;%0A//   return numPossibilities;%0A// %7D;%0A//%0A// new Change().changePossibilitiesTopDown(4, %5B1, 2, 3%5D);%0A%0Afunction changePossibilitiesBottomUp(amount, denominations) %7B%0A  var waysOfDoingNCents = %5B%5D;%0A%0A  for (var i=0; i%3C=amount; i++) %7B%0A    // initialize arrays of 0s%0A    waysOfDoingNCents%5Bi%5D = 0;%0A  %7D%0A  waysOfDoingNCents%5B0%5D = 1;%0A%0A  denominations.forEach( function(coin) %7B%0A    for (var higherAmount=coin; higherAmount%3C=amount; higherAmount++) %7B%0A      var higherAmountRemainder = higherAmount - coin;%0A      waysOfDoingNCents%5BhigherAmount%5D += waysOfDoingNCents%5BhigherAmountRemainder%5D;%0A      console.log(waysOfDoingNCents);%0A      console.log(coin);%0A    %7D%0A    console.log(%22---%22);%0A  %7D);%0A%0A  console.log(waysOfDoingNCents%5Bamount%5D);%0A  return waysOfDoingNCents%5Bamount%5D;%0A%7D%0A%0A// var results = changePossibilitiesBottomUp(5, %5B1, 3, 5%5D);%0Avar results = changePossibilitiesBottomUp(4, %5B1, 2, 3%5D);%0A// console.log(results);%0A
+makeChange() %7B%0A  %0A%7D

Remove solution from makeChange