Cash Register: test 12, fails, but looks correct?

Hello,

Hope everyone is well. I’m not sure if it’s possible for me to debug or trace the test validations, if no could someone help me with this?

It’s the cash register project:

And for example test 11:

  • When price is 3.26, the value in the #cash element is 100, cid is [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]], and the #purchase-btn element is clicked, the value in the #change-due element should be "Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04".*

These are the results I get with my solution:


And these are the results if I run the same input in the ‘demo system’ provided at the start of the intructions:


What would be the best way to get help? I imagine since my solution is getting towards being complete I shouldn’t post the full code here, or can I do it and limit the views or mark it as spoiler somehow?

Appreciate any help.

Alexander

Unfortunately we have to see the code to help. You will have to post it somewhere (here or else where).

A common issue to consider:

Do not rely on globally scoped variables. Other than cid and price, anything that modifies or reads from the cid or price or modifies the change due, needs to be locally scoped from the function that runs when purchase is clicked.

Thanks for the tip. I used a globally scoped 2D array and few variables for all my workings (executed within a few functions). I will adjust it a bit to declare those within the functions and pass parameters as necesary and see if that does it.

Hello,

Just to let you know I now have it passing all tests after moving variables into the functions etc.

Thanks for the tip !

Alexander

1 Like