So i completed second course (JavaScript Algorithms and Data Structures) but i have problems with last task “Cash register”. Code below working on all tests and site telling me that i completed whole course but i cant claim certification couse even jackdaw over “Cash register” task is here when i refresh page with tasks jackdaw disapears. Help plsplspls

```
function checkCashRegister(price, cash, cid) {
var change = [];
let diff = (cash - price).toFixed(2);
console.log('Diff =', diff)
function getAllCash(arr) {
return arr.reduce((acc, el) => {
return acc + el[1];
}, 0);
}
if(getAllCash(cid) < diff) return {
status: "INSUFFICIENT_FUNDS",
change: []
}
function getCurrency (name) {
return cid.reduce((acc, el) => {
if(el[0] === name) return acc + el[1];
return acc;
}, 0)
}
if(getCurrency("ONE HUNDRED") > 0 && diff >= 100) {
if(getCurrency("ONE HUNDRED") >= Math.trunc(diff/100)*100){
change.push(["ONE HUNDRED", Math.trunc(diff/100)*100])
diff -= Math.trunc(diff/100)*100;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["ONE HUNDRED", getCurrency("ONE HUNDRED")]);
diff -= getCurrency("ONE HUNDRED");
diff = diff.toFixed(2);
}
}
if(getCurrency("TWENTY") > 0 && diff >= 20) {
console.log('Diff =', diff)
if(getCurrency("TWENTY") >= Math.trunc(diff/20)*20){
change.push(["TWENTY", Math.trunc(diff/20)*20])
diff -= Math.trunc(diff/20)*20;
diff = diff.toFixed(2);
console.log('Diff =', diff)
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["TWENTY", getCurrency("TWENTY")]);
diff -= getCurrency("TWENTY");
diff = diff.toFixed(2);
}
}
if(getCurrency("TEN") > 0 && diff >= 10) {
if(getCurrency("TEN") >= Math.trunc(diff/10)*10){
change.push(["TEN", Math.trunc(diff/10)*10])
diff -= Math.trunc(diff/10)*10;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["TEN", getCurrency("TEN")]);
diff -= getCurrency("TEN");
diff = diff.toFixed(2);
}
}
if(getCurrency("FIVE") > 0 && diff >= 5) {
if(getCurrency("FIVE") >= Math.trunc(diff/5)*5){
change.push(["FIVE", Math.trunc(diff/5)*5])
diff -= Math.trunc(diff/5)*5;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["FIVE", getCurrency("FIVE")]);
diff -= getCurrency("FIVE");
diff = diff.toFixed(2);
}
}
if(getCurrency("ONE") > 0 && diff >= 1) {
if(getCurrency("ONE") >= Math.trunc(diff/1)*1){
change.push(["ONE", Math.trunc(diff/1)*1])
diff -= Math.trunc(diff/1)*1;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["ONE", getCurrency("ONE")]);
diff -= getCurrency("ONE");
diff = diff.toFixed(2);
}
}
if(getCurrency("QUARTER") > 0 && diff >= 0.25) {
if(getCurrency("QUARTER") >= Math.trunc(diff/0.25)*0.25){
change.push(["QUARTER", Math.trunc(diff/0.25)*0.25])
diff -= Math.trunc(diff/0.25)*0.25;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["QUARTER", getCurrency("QUARTER")]);
diff -= getCurrency("QUARTER");
diff = diff.toFixed(2);
}
}
if(getCurrency("DIME") > 0 && diff >= 0.1) {
if(getCurrency("DIME") >= Math.trunc(diff/0.1)*0.1){
change.push(["DIME", Math.trunc(diff/0.1)*0.1])
diff -= Math.trunc(diff/0.1)*0.1;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["DIME", getCurrency("DIME")]);
diff -= getCurrency("DIME");
diff = diff.toFixed(2);
}
}
if(getCurrency("NICKEL") > 0 && diff >= 0.05) {
if(getCurrency("NICKEL") >= Math.trunc(diff/0.05)*0.05){
change.push(["NICKEL", Math.trunc(diff/0.05)*0.05])
diff -= Math.trunc(diff/0.05)*0.05;
diff = diff.toFixed(2);
if(diff == 0){
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["NICKEL", getCurrency("NICKEL")]);
diff -= getCurrency("NICKEL");
diff = diff.toFixed(2);
}
}
if(getCurrency("PENNY") > 0 && diff >= 0.01) {
console.log("pennyDIFF =", diff);
if(getCurrency("PENNY") >= Math.trunc(diff/0.01)*0.01){
console.log(change)
change.push(["PENNY", Math.trunc(diff/0.01)*0.01])
console.log(change, getAllCash(change))
diff -= Math.trunc(diff/0.01)*0.01;
diff = diff.toFixed(2);
console.log("pennyDIFF2 =", diff)
if(diff == 0){
console.log(getAllCash(change), getAllCash(cid))
if(getAllCash(change) === getAllCash(cid))
return {
status: "CLOSED",
change: cid
}
return {
status: "OPEN",
change: change
}
}
}else {
change.push(["PENNY", getCurrency("PENNY")]);
diff -= getCurrency("PENNY");
diff = diff.toFixed(2);
}
}
return {
status: "INSUFFICIENT_FUNDS",
change: []
};
}
console.log(checkCashRegister(100, 220.01, [["ONE HUNDRED", 100], ["TWENTY", 20], ["PENNY", 0.03]]));
```

```
**Your browser information:**
```

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36`

**Challenge:** Cash Register

**Link to the challenge:**