Problem with color on canvas | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Problem with color on canvas

Can someone please explain what is going on? I’m doing the practice. When you tap the button the red ball is supposed to move up and the count is supposed to display in white. In my program the ball moves up but the count does not appear. Tap it again and the ball moves up and turns white. Tap more and it stays white. I added a second ball (blue) to see what would happen. Both balls are red. I changed the text color to yellow so now the balls turn yellow. https://code.sololearn.com/WG6nSiRHZByx/?ref=app

21st Sep 2022, 4:02 AM
Len
1 Answer
+ 2
Actually sololearn's js tab is just pasted in html's head while running it ... so you need to wait for dom to be loaded before doing any dom manupulation ... on way to do so is wrapping everything in onload or onDOMContentLoaded . also dont use = for fill text as its a function . + There's typo in fillStyle line 15 45 & 22 https://code.sololearn.com/W3YkU51dBqdp/?ref=app
21st Sep 2022, 4:29 AM
Prashanth Kumar
Prashanth Kumar - avatar