Question about the Cash Register project

how is the data in the cash in drawer matched. i don’t quite get it ???

Welcome, faalisco.

Would you mind being more specific as to what you do not understand? Are you wanting the tests explained?

The tests can be seen here: freeCodeCamp/ at master · freeCodeCamp/freeCodeCamp (

The data is passed as a multidimensional array to the function call, the third argument, each grade (“PENNY”, “NICKEL” etc) has associated a value.

checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);

Then inside the function, the values provided above are mapped against the values contained in the array provided as a base.

var denom = [
    { name: 'ONE HUNDRED', val: 100},
    { name: 'TWENTY', val: 20},
    { name: 'TEN', val: 10},
    { name: 'FIVE', val: 5},
    { name: 'ONE', val: 1},
    { name: 'QUARTER', val: 0.25},
    { name: 'DIME', val: 0.1},
    { name: 'NICKEL', val: 0.05},
    { name: 'PENNY', val: 0.01}

As a matter of fact “denom” should be a JavaScript Map rather than an array of objects. (Please do not confuse method to the Map ) but I suppose that the intention was to keep things simple.

You should think of the checkCashRegister arguments as the state and the “denom” array as a concept, that represents monetary denomination.
(I am sure you know how to use money)

This is what would be materialised in the real world.

Hope this helps.

no, what i dont get is the first and the next value in the inner arrays. does the value means thats the total number of the previous value?? e.g [‘penny’, 1.02] means sum of penny is 1.02??

yes, there is written that there are 1.02$ in pennies