Cash Register_Requesting Help with Understanding Solution

Hello. I’m reading fCC’s solution to the cash register problem:

https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register/

I don’t understand what acc[curr[0]] = curr[1]; does in:

var register = cid.reduce(function(acc, curr) {
    acc.total += curr[1];
    acc[curr[0]] = curr[1];
    return acc;
  }, { total: 0 });
1 Like

I also don’t understand register[curr.name] in:

    // While there is still money of this type in the drawer
    // And while the denomination is larger than the change remaining
    while (register[curr.name] > 0 && change >= curr.val) {
      change -= curr.val;
      register[curr.name] -= curr.val;
      value += curr.val;