# Assessment wanted for Adding bouncing balls features (Issues with counter)

**URL:** <https://discourse.mozilla.org/t/assessment-wanted-for-adding-bouncing-balls-features-issues-with-counter/66208>\
**Category:** Learn\
**Created:** [August 22, 2020, 9:58pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-adding-bouncing-balls-features-issues-with-counter/66208 "2020-08-22T21:58:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dzhangir\_Bayandarov](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dzhangir\_Bayandarov](https://discourse.mozilla.org/u/Dzhangir_Bayandarov)\
**Post date:** [August 22, 2020, 9:58pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-adding-bouncing-balls-features-issues-with-counter/66208/1 "2020-08-22T21:58:21Z")

</div>

[https://github.com/Dzhango/bouncing-balls.git](https://github.com/Dzhango/bouncing-balls.git)

I have completed everything except for the ball counter.

If you could please give me a hint on how to address the counter. I am getting either a zero when I initialize ballcount variable, or I get a lot of different random numbers.

Also, question: does having class based structure allows me to neglect the prototypes, since Shape is the Parent class, so I simple call super in EvilCircle and Ball.

Thank you!

---

<div class="post-metadata">

**Author:** ![Rafael\_Green](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@Rafael\_Green](https://discourse.mozilla.org/u/Rafael_Green)\
**Post date:** [August 23, 2020, 3:21am UTC](https://discourse.mozilla.org/t/assessment-wanted-for-adding-bouncing-balls-features-issues-with-counter/66208/2 "2020-08-23T03:21:01Z")

</div>

first, congrats for your first post and welcome to the community.

about the counter,  
you initilized it with 0 as expected.  
but you should move the `ballNum += 1` and `ballNum -= 1` to more appropriate places:  
move the `ballNum += 1` to the place in the code where you create a ball  
move the `ballNum -= 1` to the place in the code where you remove a ball  
also don’t forget to actually update the counter’s dom element when you update the counter’s value (for example like this: `counter.textContent = `Ball Count: ${ballNum}`;`).

also, change this line: `if(this.exists)` to `if(balls[j].exists) {`  
in this case, the `this` is the evil ball which always exists. you want to check if the other ball exists

In addition, when drawing the evil circle you want to use ` ctx.stroke();` and not `ctx.fill();`

about your second question, when you use the class syntax you don’t have to deal with prototypes (it will be automatically managed for you)

if you have more questions or still struggling with the exercise feel free to ask for more help

---

<div class="post-metadata">

**Author:** ![Dzhangir\_Bayandarov](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@Dzhangir\_Bayandarov](https://discourse.mozilla.org/u/Dzhangir_Bayandarov)\
**Post date:** [August 23, 2020, 5:58am UTC](https://discourse.mozilla.org/t/assessment-wanted-for-adding-bouncing-balls-features-issues-with-counter/66208/3 "2020-08-23T05:58:27Z")

</div>

It works! Thank you, so much!
