0

Can someone explain to me why the setInterval can not take the function that draws the rectangle as argument?

Functions https://code.sololearn.com/WMr2aM5hLPSl/?ref=app

4th Jul 2022, 5:54 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar
7 Respostas
+ 3
Make your life easier: 1. Split web code in the specific files (tabs in Code Playground): HTML, CSS and JS. Mixing them all always gets quite messy and hard to debug. 2. Use proper indentation. It's meant exactly to make code more readable (and work, in Python).
4th Jul 2022, 6:05 PM
Emerson Prado
Emerson Prado - avatar
+ 2
Patrick agbenyo paul Yes. It's supposed to be an answer, and also to keep your soul healthier. Trust that: easier to read is easier to debug and fix. That said, what makes you think setInterval can't take your function? I ran it without issues. But it always draws the same thing in the same place. If you expect the circle to move, you have to erase the previous one and redraw somewhere else.
4th Jul 2022, 6:16 PM
Emerson Prado
Emerson Prado - avatar
0
Thks buh it a small code and I need answers cuz d problem it's eating up my soul
4th Jul 2022, 6:08 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar
0
Thks pls how do I do that
4th Jul 2022, 7:09 PM
Patrick agbenyo paul
Patrick agbenyo paul - avatar
0
Patrick agbenyo paul To erase, just redraw with the background color. To draw in arbitrary places, add position parameters in the draw function.
4th Jul 2022, 10:30 PM
Emerson Prado
Emerson Prado - avatar
0
Patrick agbenyo paul Before anything, follow my first hints on tabs and indentaion. It's an easy job, and will make the real hard ones easier.
4th Jul 2022, 10:40 PM
Emerson Prado
Emerson Prado - avatar
0
Yeah thks I will get beta and beta day by day
5th Jul 2022, 12:47 AM
Patrick agbenyo paul
Patrick agbenyo paul - avatar