Tell us what’s happening:
Describe your issue in detail here.
Hello,
I am trying to complete the last javascript exercise - Cash Register.
The last else statement cause only the first test to pass.
If I remove the last ‘else’ statement, the the last three tests pass.
Does anyone know why this is and how I can fix this problem
Thank you
**Your code so far**
function checkCashRegister(price, cash, cid) {
let change;
change = cash - price;
for (var i = 0, l1 = cid.length; i < l1; i++) {
for (var j = 0, l2 = cid[i].length; j < l2; j++) {
if (cid[i][j] < change) {
const cool = {status: "INSUFFICIENT_FUNDS",change: []}
return cool;
} else if (cid[i][j] === change) {
const myobj = {status: "CLOSED", change: cid}
return myobj;
} else {
const car = {status: "OPEN", change: []}
return car;
}
}
}
}
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/102.0.5005.124 Safari/537.36 Edg/102.0.1245.41
Challenge: Cash Register
Link to the challenge: