Firstly, I would like to admit that Cash register is one of the most interesting and complex problem. It took me few days to get my mind around this problem and come up with a solution.

I hope Quincy accepts it as a pass for Cash register problem and I can proudly put the JavaScript Algorithms and Data Structures certification on my desk…

I would love to get some feedback from seniors on my solution, wondering if they consider it as a pass or fail.

# How I divided the problem

I divided the problem into three simple scenarios:

- find out if the
**due**is an integer number or floating point number - if it is an integer number, simply generate the possible combinations of currencies that totals up to
**due** - if it is a floating point number, divide the
**due**at the point into upper class value and lower class value, and then find possible combinations of currencies that totals up to each extreme values

# Possible brain fades

When you try to find possible matches for either floating point number or integer number, try to take into consideration, how *Number* literal, * fixedTo()* method,

*Remainder*operator behaves in JavaScript.

# Extra homework

I spent way too much time figuring out a solution to this problem. My test cases are performing better than what I expected. One major case where **due** is 96.74, my solution gives a change of following data structure:

```
[
[
"TWENTY",
80
],
[
"TEN",
10
],
[
"FIVE",
5
],
[
"ONE",
1
],
[
"QUARTER",
0.5
],
[
"DIME",
0.2
],
[
"PENNY",
0.04
]
]
```

Unfortunately, my logic will only work when Cash register has only 3 bills of $20. In such case, you will see expected output as needed to pass the problem.

# Additional Test Cases

I wanted to write logic in a way to support all edge cases. Because, as we are humans, I cannot possibly test all cases that a machine can do. But, whatever loopholes I found when working at the problem, I tried to address it. Following are some cases that passes with this logic:

```
// ADDITIONAL TEST CASES
// checkCashRegister(19, 20, [
// ["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 1]
// ])
// checkCashRegister(19, 200, [
// ["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 1]
// ])
// checkCashRegister(18.5, 20, [
// ["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 1]
// ])
// checkCashRegister(18.2, 20, [
// ["PENNY", 0],
// ["NICKEL", 0.8],
// ["DIME", 0],
// ["QUARTER", 0],
// ["ONE", 1],
// ["FIVE", 2],
// ["TEN", 2],
// ["TWENTY", 2],
// ["ONE HUNDRED", 2]
// ])
```

# Learning Outcome

I feel proud to have accomplished a working solution on my own. It may be ugly, long, unreadable, messy, sloppy or anything bad you can think of. At the end of the day, positive takeaway for me was to able to see through a logic that meets minimum possible requirements to solve the problem. It may be tough for most people but I advice people to keep at it and reward will be much satisfactory once you see the working solution of your own.