function drawer(price, cash, cid) {
var change = cash - price;
var total = cid[0][1] + cid[1][1] + cid[2][1] + cid[3][1] + cid[4][1] + cid[5][1] + cid[6][1] + cid[7][1] + cid[8][1];
if(total < change) {
return "Insufficient Funds";
} else if(total == change) {
return "Closed";
} else {
return ...; // will determine exact change at this point and things get very very messy
}
}
drawer(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
var currOp = function() {
if (arguments[0]) {
this.value = arguments[0];
return;
} else {
return this.value;
}
};
heres mine.. need to work on a few things though.. best viewed in browser...