// create a 2D array
let cidTwoDArray = [
['ONE HUNDRED', 10000],
['TWENTY', 2000],
['TEN', 1000],
['FIVE', 500],
['ONE', 100],
['QUARTER', 25],
['DIME', 10],
['NICKEL', 5],
['PENNY', 1]
];
// sort the array in descending numerical order for clarification
function checkCashRegister(price, cash, cid) {
let alphaArray = ['ONE HUNDRED', 'TWENTY', 'TEN','FIVE', 'ONE', 'QUARTER', 'DIME', 'NICKEL', 'PENNY']
// use Math.round on the array to round up/down to the nearest whole number
arrayAlpha.sort();
console.log(arrayAlpha);
let alphaOneHundred = 100.00;
alert(Math.round(alphaOneHundred));
let alphaTwenty = 20.00;
alert(Math.round(alphaTwenty));
let alphaTen = 10.00;
alert(Math.round(alphaTen));
let alphaFive = 5.00;
alert(Math.round(alphaFive));
let alphaOne = 1.00;
alert(Math.round(alphaOne));
let alphaQuarter = 0.25;
alert(Math.round(alphaQuarter));
let alphaDime = 0.1;
alert(Math.round(alphaDime));
let alphaNickel = 0.05;
alert(Math.round(alphaNickel));
let alphaPenny = 0.01;
alert(Math.round(alphaPenny));
// use if statement to check the status of the cid
if (cash in draw < price) {
return {status: "INSUFFICIENT_FUNDS", change:[]}
if (cash in draw === price) {
return {status: "CLOSED", change:[]}
if (cash in draw > price) {
return {status: "OPEN", change:[]}
return change;
}
// Here is your change, ma'am.
}
// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 100]]
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]]);