Hello all. I’m on the last JavaScript project and I’m kindof perplexed. I understand what the project wants me to do, I’m just having trouble actually doing it. I’m hoping by writing it out it will jog something in my brain. Also please correct me if I’m mistaken about something.
These parts are working:
-Create an array to store denomination
of each type of bill. ie: name: ONE HUNDRED, val: 100.00
-Declare a blank array to store ouput
.
-Declare a change
due variable that is (cash
in hand - price
of item).
-Declare a register
variable that runs reduce through the cid
array.
–The returned value is a total
amount of money in the register
.
These parts are causing problems:
-If the register.total
is equal to the cash
in hand…
–Then output.status
needs to equal “CLOSED”.
–And output.change
should be a copy of the cid
array. (Because all the change is going.)
-If the register.total
is less than cash
in hand…
–Then output.status
needs to equal “INSUFFICIENT_FUNDS”.
–And output.change
needs to return a blank array. (Because there’s no change.)
-Otherwise, it’s assumed register.total
is greater than cash
in hand so…
–The output.status
needs to equal “OPEN”.
–With a for loop, it needs to go through each value
in the register
until it finds a denomination.val
that is smaller than the change
due. ie: If change is $.50, it runs until it reaches QUARTER and subtracts $.25, and then subtracts $.25 again.
–Each time the register
finds the right denomination.val
, it should add the amount to the output.change
array, and the output.name
as well.
-And finally output.change
is returned. (Because some change is going.)
… This is a doozy of a project. I guess that’s why it’s the last one in the certificate!