I seriously can not believe my luck.
The code passes all of the tests except the 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]]}.
Which doesn´t pass because my code return the same except [“PENNY”, 0.03] instead of [“PENNY”, 0.04] 
Basically my code consists in a loop
var reference = 0 //stop loop when reference value becomes 96.74
for (var i=fromthere; i > -1; i--){
let counter = quantityofCoins[i]
for (var j=0; j<counter;j++){
if (reference > toReturn){
cidtoReturn[i][1] -= typeofCoin[i]
reference -= typeofCoin[i]
break;
}
cidtoReturn[i][1] += typeofCoin[i]
reference += typeofCoin[i]
}
}
Here are what each variable in the loop means:
“fromthere” it´s just the index from where the loop must start going. Thanks to this code it changes depending to the amount there is to return:
var closest = typeofCoin.reduce(function(prev, curr) {
return (Math.abs(curr - toReturn) < Math.abs(prev - toReturn) ? curr : prev);
});
if (toReturn < closest){
var fromthere = typeofCoin.indexOf(closest) - 1
}
else {
var fromthere = typeofCoin.indexOf(closest)
}
So in this test fromthere will be 7, which mean the loop will start counting from the “TWENTY” currency, instead from the “HUNDRED”
The rest of variables I use in the loop:
var toReturn = cash - price
var cidtoReturn = [["PENNY", 0], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE",0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]
var typeofCoin = [0.01,0.05,0.10,0.25,1,5,10,20,100]
var quantityofCoins = [cid[0][1]/0.01, Math.round(cid[1][1]/0.05), cid[2][1]/0.1,cid[3][1]/0.25, cid[4][1], cid[5][1]/5, cid[6][1]/10, cid[7][1]/20, cid[8][1]/100]
I think the main problem is my code doesn´t actually stop when it reaches exact 96.74 but rather it just substract the last value added if it surpassed toReturn, and then exists the loop. Magically it kind of works but in this case it doesn´t for some reason.
Can I slightly modify it withouth messing the other tests, to actually return the penny left it supposed to return? Or should I change a lot?.
----This is the FULL code in case anybody wants to test it in his machine: