Cash Register javascript challenges

Tell us what’s happening:
I’m not close to coming up with a solution yet. But i think converting the 2D array to an object would be easier to work with. For some reason the method fromEntries doesn’t work. The array is a iterable object correct? I tried running the sample code on the Mozilla DEveloper Network concerning this method and their sample code doesn’t work either.

Your code so far

function checkCashRegister(price, cash, cid) {
  var change;
  // Here is your change, ma'am.
  var objCid = Object.fromEntries(cid);
  return change;

// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 100]]

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 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.

Link to the challenge:

In this case , no: you likely want to be able to iterate over it, having access to array methods makes the challenge much easier.

Re second point: Look at the browser compability. fromEntries is a proposal from this year, it’s not finalised in any way and only works in bleeding-edge Firefox, where they are checking if it’s feasible to add to the standard library. It is not part of the language yet. If you really want to convert the map to an object, then you need to do it manually.

.fromEntries() will not work just yet, at least on V8. I think you’re correct about converting it to object, but for now you’ll need .reduce() or .forEach() to convert