0
Can someone help figure out what's wrong with my code?
I've already tried, unsuccessfully, to debug my code but I cant find out what's wrong. The code is meant to spawn two circles at random coordinates on the screen and move them to the right until they reach the right hand side of the screen whereupon they are deleted. However, when one of the circles reaches the end one of three things happens: the wrong one gets deleted, it performs as intended, or everything gets deleted. https://code.sololearn.com/W5zsWYNKG0mO/?ref=app
1 Respuesta
+ 3
you try to remove item at index i with pop() method, but pop() doesn't expect any arguments, and just remove the last item...
you need the splice() method:
circleArray.splice(i,1)
arguments:
+ start index
+ number of items to remove
+ how many optional items to be inserted