[Object] inside array and some wierd error

Tell us what’s happening:

Hello as you can see in output it return change: [ [ [Object] ], [ [Object] ], why is this happening
Also it returned penny at the end as [ 'PENNY', 0.03 ] ] } i think i need to round somevalue.
Please point me right direction

Thanks

Your code so far


function checkCashRegister(price, cash, cid) {
let change=cash-price;
let unitValMap=[0.01,0.05,0.1,0.25,1,5,10,20,100];
let totalChangeCID=0;
let newCID=[];

let findValue=function(totalInCID,change,unitVal){
          let factor = change/unitVal;
              let val = Math.floor(factor)*unitVal
            return val;

}
for(const el of cid){
  totalChangeCID+=el[1];
}
if(totalChangeCID<change){
  return {status: "INSUFFICIENT_FUNDS", change: []};
}else if(totalChangeCID==change){
  return {status: "CLOSED",change: cid};
}else{
  for(let i=cid.length-1;i>=0;i--){

      if(change>unitValMap[i]){
        if(change<cid[i][1]){
          let valueToSubtract=findValue(cid[i][1],change,unitValMap[i])
              change-=valueToSubtract
              newCID.push([cid[i][0],valueToSubtract])
        }else{
          if(change>0){
          change-=cid[i][1];
          newCID.push([cid[i]]);
          }
        }
      }
  }
}
// Here is your change, ma'am.
return {status: "OPEN", change: newCID};
}

console.log(checkCashRegister(3.26, 100, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]));
/*{ status: 'OPEN',
  change: 
   [ [ [Object] ],
     [ [Object] ],
     [ 'FIVE', 15 ],
     [ 'ONE', 1 ],
     [ 'QUARTER', 0.5 ],
     [ 'DIME', 0.2 ],
     [ 'PENNY', 0.03 ] ] }
*/

Your browser information:

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

Challenge: Cash Register

Link to the challenge:

UPDATE : I solved my rounding problem using toFixed().
UPDATE I also solved both problems

you can use JSON.stringify() to print complex objects

I solved it, it was due to some mistake in push syntax, thanx ieahleen