Error with test cases on Cash Register problem?

Tell us what’s happening:
Hello, I believe there to be an error with the OPEN test cases for this problem. My code outputs EXACTLY what the problem expects, yet it still refuses it. The other test cases work fine.
I’ve tried verifying that data types match, making sure they have the same whitespace, ensuring the format is the same, even copy-pasting the expected output status from the instructions into my variable, but every time those test cases fail. At this point, I think the problem itself has an error, but maybe I am just giga-blind. Please lemme know which is the case.

  **Your code so far**

function checkCashRegister(price, cash, cid) {
//creating a copy of cid to work with
let avail = cid;
let drawerTotal = 0;
cid.forEach(i=>{drawerTotal += i[1]});
let change = cash - price;
let temp = change;
let output = {'status': "INSUFFICIENT_FUNDS",'change': []}
if(cash < price)return output;
if(cash === price || drawerTotal === change)return {'status': "CLOSED", 'change': cid}
let vals = [['PENNY',.01],['NICKEL',.05],['DIME',.1],['QUARTER',0.25],['ONE',1],['FIVE',5],['TEN',10],['TWENTY',20],['FIFTY',50],['ONE HUNDRED',100]];
//inserting monetary values into each array
vals.forEach(i=>{
  for(let j = 0; j < avail.length; j++){
    if(avail[j][0]===i[0]){
      avail[j].push(i[1]);
      break;
    };
  }
});
//where the change gets converted into output format
output.status = "OPEN";
//output = {'status': "OPEN",'change': []}
for(let i = avail.length - 1; i > -1; i--){
  //counter for coins and bills
  let count = 0;
  while(temp >= avail[i][2] ){
    //for each currency, subtract its value from the current change amount until change is less than the value
    temp = parseFloat(temp - avail[i][2]).toFixed(2);
    count++;
    if(avail[i][2] * count >= avail[i][1]){
      break;
    }
  }
  //pushes if there were subtractions
  count > 0 ? output.change.push([avail[i][0], avail[i][2] * count]) : '';
}
console.log(output)
return change == 0 ? output : {'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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Cash Register

Link to the challenge:

Nevermind, I have solved my issue

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