# JavaScript Algorithms and Data Structures Projects - Cash Register

### Tell us what’s happening:

Can someone help me, I can’t make the correct form of the string.

function checkCashRegister(price, cash, cid) {
let change = cash - price;
let cashIn = cid.reduce((acc, curr) => acc + curr[1],0).toFixed(2);
let currAmt = [["PENNY", .01], ["NICKEL", .05], ["DIME", .1], ["QUARTER", .25], ["ONE", 1], ["FIVE", 5], ["TEN", 10], ["TWENTY", 20], ["ONE HUNDRED", 100]];
currAmt.reverse();
cid.reverse();
for(let i = 0;i < currAmt.length;i++){
if(cashIn < change || change / currAmt < 1){

console.log ({status: "INSUFFICIENT_FUNDS", change: []});
}
if(cashIn == change){
console.log({status: "CLOSED", change: cid.reverse()});
}
if(change / currAmt[i][1] < 1){
let chtG = cashIn -cid[i][1];

if (change > chtG){

console.log({status: "ISUFFICIENT_FUNDS", change: []});

}
if (change < chtG){

for(let j in currAmt){
if(change / currAmt[j][1] >= 1){
let chMon = Math.floor(change / currAmt[j][1]) * currAmt[j][1];
if (chMon > cid[j][1]){
change -= cid[j][1];
change = change.toFixed(2);

}
if (chMon < cid[j][1]){
change -= chMon;
change = change.toFixed(2);
cid[j][1] -=  (cid[j][1] - chMon);}

if(cid[j][1] < .5){
cid[j][1] = cid[j][1].toFixed(2);
}
let result = '';
result+= (cid[j]);
console.log(result)
}
}
}
}
}

}

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