I basically wasted 2 hours to debug my code because I don’t know the right method to
increment or decrement the count. I have no choice but look at the source code of the finished example.
my original code on score count:
let para=document.querySelector('p')
let count=0;
for (const ball of balls) {
if (balls.length++&&ball.exists){
count++;
}
if (ball.exists===false){
count--;
}
}
para.textContent=`Ball count:${count}`;
I write these lines at the bottom of the js file. It’s truly a disaster