# Need help for "Cash Register" Project

**URL:** <https://forum.freecodecamp.org/t/need-help-for-cash-register-project/328093>\
**Category:** General\
**Created:** [November 25, 2019, 1:13pm UTC](https://forum.freecodecamp.org/t/need-help-for-cash-register-project/328093 "2019-11-25T13:13:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bam92](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bam92/32/128056_2.png) [@Bam92](https://forum.freecodecamp.org/u/Bam92)\
**Post date:** [November 25, 2019, 1:13pm UTC](https://forum.freecodecamp.org/t/need-help-for-cash-register-project/328093/1 "2019-11-25T13:13:09Z")

</div>

Hi!

I am trying to resolve the algorithm challenge named " Cash Register". Everything is working fine, except that one user story is failing. The test that fails is 3. I find [“PENNY”, 0.03] instead of [“PENNY”, 0.04]. My solution is below:

```auto
let change = cash - price;
      let test = cash - price;
      let total = 0;
      let remaining = 0;
      const output = [];
      const cidReverse = cid.reverse();
      
   const currencies = [
    {name: 'ONE HUNDRED', amount: 100},
    {name: 'TWENTY', amount: 20},
    {name: 'TEN', amount: 10},
    {name: 'FIVE', amount: 5},
    {name: 'ONE', amount: 1},
    {name: 'QUARTER', amount: 0.25},
    {name: 'DIME', amount: 0.1},
    {name: 'NICKEL', amount: 0.05},
    {name: 'PENNY', amount: 0.01}
   
];
      const currencyInfo = (currency) => currencies.find(curr => curr.name === currency);
      
      cidReverse.forEach(currArr => {
      const currencyValue = currencyInfo(currArr[0]).amount;
      
      const temp = []
      remaining += currArr[1]
         
      if (change >= currencyValue || change >= currArr[1]) {
         temp.push(currArr[0]);
         const possibleBills = Math.floor(change / currencyValue) * currencyValue;
         
         if (change > 0) {
             if (possibleBills > currArr[1]) {
               temp.push(currArr[1])
               change = (possibleBills - currArr[1]) + (change % currencyValue)
                
         } else {
            temp.push(possibleBills)
            change = change % currencyValue
            }
         }
         
         total += temp[1]       
         
      output.push(temp)
         
      }
 
})
      
      let status = "OPEN";
      let change1 = output;
      
      if (remaining === test) {
         status = "CLOSED";
         change1 = change1.reverse();
      }
     
      if (total !== (cash - price)) {
         status = "INSUFFICIENT_FUNDS";
        // change1 = [];
      }
      
      
      return {
         status,
         change: change1
      }

```

Can I get help on how to fix my algo logic?

---

<div class="post-metadata">

**Author:** ![popezandy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@popezandy](https://forum.freecodecamp.org/u/popezandy)\
**Post date:** [December 4, 2019, 6:08pm UTC](https://forum.freecodecamp.org/t/need-help-for-cash-register-project/328093/2 "2019-12-04T18:08:01Z")

</div>

Hey Bam, in the Hints page solution on this project, they mention accounting for calculation error by rounding change to the nearest hundredth place (Math.round(change \* 100) / 100). I had the same issue, and figuring out where was appropriate to reassign rounded results was a bit of a challenge, but once I did that solved it for me.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:31am UTC](https://forum.freecodecamp.org/t/need-help-for-cash-register-project/328093/3 "2021-01-16T11:31:15Z")

</div>

Closed on January 16, 2021, 11:31am UTC


