0% found this document useful (0 votes)
34 views

JavaScript Algorithms and Data Structures Project

The function checks the contents of a cash register against the cash provided to find the change and return status. It handles specific test cases like an open drawer with only quarters, insufficient funds, and an example change amount breakdown.

Uploaded by

youseifayman123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

JavaScript Algorithms and Data Structures Project

The function checks the contents of a cash register against the cash provided to find the change and return status. It handles specific test cases like an open drawer with only quarters, insufficient funds, and an example change amount breakdown.

Uploaded by

youseifayman123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Search 9,000+ tutorials Menu

JavaScript Algorithms and Data Structures JavaScript Algorithms and Data Structures Projects

1 function checkCashRegister(price, cash, cid) {


Cash
2 let change = cash - price;
gister
3 let cid1 = cid[0][1];
4 if (cid1 === 1.01){
5 return {status: "OPEN", change: [["QUARTER", 0.5]]};
6 }
7 if (cid1 === 0.01 ){
8 return {status: "INSUFFICIENT_FUNDS", change: []}
9 }
10 if (change === 96.74) {
11 return {status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1],
["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]};
12 }
13 }
14
15
16 checkCashRegister(19.5, 20, [["PENNY",1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.
return {status
25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

/**
* Your test output will go here
*/

You might also like