JavaScript Algorithms and Data Structures Projects - Cash Register

Tell us what’s happening:
Please can someone tell me why my code doesn’t work. The console output seems fine but it couldn’t pass the test.

Your code so far

function checkCashRegister(price, cash, cid) {
  var change=Math.round((cash-price)*100)/100;
  var sum=Math.round((cid.reduce((a,b)=>a+b[1],0))*100)/100;
  var changearr=[];
  const table=[0.01,0.05,0.1,0.25,1,5,10,20,100];
  if(change===sum){return console.log({status: "CLOSED", change: cid})}
 else { for(let i=cid.length-1; i>=0; i--){
   var value=0;
   while(cid[i][1]>0&&change>=table[i]){
 change-=table[i];
 cid[i][1]-=table[i];
 value+=table[i];
 change=Math.round(change * 100) / 100;
   } if(value>0){changearr.push([cid[i][0],value])}
 }
return change===0? console.log({status: "OPEN", change: changearr}): console.log({status: "INSUFFICIENT_FUNDS", change: []});
 }
}
    
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_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Cash Register

Link to the challenge:

remove the console.logs at the end. also you are still failing the last case

actually remove all console logs and your good to go

Thank you so much! It works!

When you return console.log, you are returning the exit code for the consoe.log function, not the stuff you actually logged

Ahhh that makes so much sense. Thank you