DEV Community

Andrew Jackson
Andrew Jackson

Posted on

counters != countersWorking; SOLVED

Hey everyone as for the title I am having trouble with my counters not working. They are itemCounts and discountCounts. They are arrays that hold the value of ITEM_NAMES.length and DISCOUNT_NAME.length. This is a school practice project and those are the values I was given but I am not sure on how to use them to count the number of time the item or discount has been selected. Usually I would just use........... BARRROOOOOO!!!

I literally just figured out what my problem was. I just realized I am using arrays and because I am also using an if statement to check if it is the correct item I could just used that array point like so:

itemCounts[0]++;

I guess I was overthinking it the whole time because I was scared of failing and looking stupid.

Well thanks for your help?

The project is a gist here;

Top comments (0)