# Who can help me with algoritm and data structure in Cash Register quiz?

Hello every one) I have wroten a function to pass Cash Register quiz, but still I can not pass some tests:

``````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]]) should return {status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]}

checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return {status: "INSUFFICIENT_FUNDS", change: []}

//MY FUNC:
function checkCashRegister(price, cash, cid) {
let buying = cash - price;
let start=0
let acum = cid.map(el=>{
start = start+el[1]
})

let resultArr=[];
cid= cid.reverse();
// Example cash-in-drawer array:
let cashArr =[["PENNY", 0.01],
["NICKEL", 0.05],
["DIME", 0.1],
["QUARTER", 0.25],
["Dollar", 1],
["Five Dollars", 5],
["TEN", 10],
["TWENTY", 20],
["ONE HUNDRED", 100]]

cashArr=cashArr.reverse()

return {status: "INSUFFICIENT_FUNDS", change: []}
return {status: "CLOSED", change: cid.reverse()}
}
arr.map((el,i) => {

} else  {
return {status: "INSUFFICIENT_FUNDS", change: []}
}

});
}

console.log(resultArr);

return {status: "OPEN", change: resultArr}
}
``````

What needs to be done for the function to work?

What do the failing tests say?

// running tests

``````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]])
``````

should return

``````{status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]}
``````

.

``````checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]])
``````

should return

``````{status: "INSUFFICIENT_FUNDS", change: []}
``````

. // tests completed // console output 0.5 335.40999999999997 [[“QUARTER”,0.5]]

``````[["PENNY", 0.01],
["NICKEL", 0.05],
["DIME", 0.1],
["QUARTER", 0.25],
["Dollar", 1],
["Five Dollars", 5],
["TEN", 10],
["TWENTY", 20],
["ONE HUNDRED", 100]]
``````

One of these things is not like the others…
(Two, actually)