Cash Register...need help!

Tell us what’s happening:

I keep getting an error saying that curr is not defined. I’ve been working on this code all day and I feel like it’s a simple solution that I keep overlooking. Any help is appreciated. TIA

Your code so far


function checkCashRegister(price, cash, cid) {
  var output = {status: null, change: [] };
  var change = cash - price;
  var register = cid.reduce(
    function(acc, cur) {
    acc.total += curr[1];
    acc[curr[0]] = curr[1];
    return acc;
  }, { total: 0 });

  if (register.total === change) {
    output.status = 'CLOSED';
    output.change = cid;
    return output;
  }
  if (register.total < change) {
    output.status = 'INSUFFICIENT_FUNDS';
    return output;
  }

  var change_arr = denom.reduce(function(acc, curr) {
    var value = 0;
    while (register[curr.name] > 0 && change >= curr.val) {
      change -= curr.val;
      register[curr.name] -= curr.val;
      value += curr.val;
      change = Math.round(change * 100) / 100;
    }
    if (value > 0) {
      acc.push([curr.name, value]);
    }
    return acc;
  }, []);

  if (change_arr.length < 1 || change > 0) {
    output.status = 'INSUFFICIENT_FUNDS';
    return output;
  }
  output.status = 'OPEN';
  output.change = change.arr;
  return output;
}
var denom = [
   ["PENNY", 1],
   ["NICKEL", 5],
   ["DIME", 10],
   ["QUARTER", 25],
   ["ONE", 100],
   ["FIVE", 500],
   ["TEN", 1000],
   ["TWENTY", 2000],
   ["ONE HUNDRED", 10000]
 ];
 
checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register

Okay so curr is not defined was a simple typo mistake…UGH

But now I can’t get this code to pass the 2nd and third tests…

   function(acc, cur) {

In this line the variable only has one “r”.