Cash register project Borem try

hello my friend can someone help me to fix this code firstly iwant to find the exact result to the second testhttps://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register

function checkCashRegister(price, cash, cid) {
  var change = [];
  let valor = {
    "PENNY": 0.01,
    "NICKEL": 0.05,
    "DIME": 0.1,
    "QUARTER": 0.25,
    "ONE": 1,
    "FIVE": 5,
    "TEN": 10,
    "TWENTY": 20
  };
   var Obj = {};
 let total = 0;
 let newMoney;
 let coef;
  let peices = [];
  let rest = (cash - price).toFixed(2);
  cid.reverse()
if(rest <= 100) {
  cid.shift()
}
for(let money of cid) {
  if(rest > 1) {
if(rest > money[1]) {
  rest -= money[1];
  
  peices.push(money)
} else if(rest < money[1]) {
coef = Math.floor(rest / valor[money[0]]);
console.log(coef)
newMoney = coef * valor[money[0]];

money.pop()
money.push(newMoney)
money.push(peices)
}
  }
}
 console.log(peices)
   
}

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register
please can someone help me to fix the second and the final test please

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.