# Javascript project cash register return format question

**URL:** <https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 11, 2018, 8:33pm UTC](https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231 "2018-10-11T20:33:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![a2937](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/a2937/32/253267_2.png) [@a2937](https://forum.freecodecamp.org/u/a2937)\
**Post date:** [October 11, 2018, 8:33pm UTC](https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231/1 "2018-10-11T20:33:41Z")

</div>

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register)**
>
> Learn to Code — For Free

What exactly are the proper specifications for output? In the third test, nickels are not listed in the array. It also worth noting there are none in the change returned. Is it supposed to be that way? If so, I will need help removing that section from my return statement.

> **Summary**
>
> `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]])` should return `{status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]}`

In the last test, the output is in a exact opposite order from the above. I suppose that has to do with sorting the change array.

> **Summary**
>
> `checkCashRegister(19.5, 20, [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]])` should return `{status: "CLOSED", change: [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]}`

---

<div class="post-metadata">

**Author:** ![JordanMarsh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordanmarsh/32/102627_2.png) [@JordanMarsh](https://forum.freecodecamp.org/u/JordanMarsh)\
**Post date:** [October 11, 2018, 8:54pm UTC](https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231/2 "2018-10-11T20:54:12Z")

</div>

The question states it but it can be a bit confusing.

If the cash register has exact change, you return an array of the entire drawer (your summary #2 above) and status closed.

If the cash register has more than enough change, you return an array of the exact change and in what denominations it was returned with the status open.

---

<div class="post-metadata">

**Author:** ![snowmonkey](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/snowmonkey/32/241579_2.png) [@snowmonkey](https://forum.freecodecamp.org/u/snowmonkey)\
**Post date:** [October 11, 2018, 8:59pm UTC](https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231/3 "2018-10-11T20:59:09Z")

</div>

Also, in the given example, using everything down to dimes gets you to $96.70 - so nickels would not be in the return array (or would return pointlessly, with a value of 0.00).

However, the order of the returned results don’t really matter, so long as the proper “keys” are in place, i.e., the currency names. Personally, I started from largest to smallest, then simply unshifted values onto the array I was returning, thus returning the smallest-to-largest order. Why? I don’t know. Could have pushed rather than unshifted, but there it is

---

<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:** [February 2, 2021, 11:27am UTC](https://forum.freecodecamp.org/t/javascript-project-cash-register-return-format-question/233231/4 "2021-02-02T11:27:48Z")

</div>

Closed on February 2, 2021, 11:27am UTC


