Not the results I wanted [solved] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Not the results I wanted [solved]

Hey guys, in this code I wanted to make a square move with setInterval but the square won’t move I hope someone could find the prob https://code.sololearn.com/WZKhfClm85iA/?ref=app

26th Jan 2019, 10:29 PM
saif Zak
saif Zak - avatar
8 Answers
+ 2
Ah, I didn't realise you already had it there. All you need to do is remove the brackets/parentheses. setInterval(update, 20); NOT setInterval(update(), 20);
27th Jan 2019, 1:30 PM
James
James - avatar
+ 1
James now I feel like an idiot🤦‍♂️😂
27th Jan 2019, 4:39 PM
saif Zak
saif Zak - avatar
+ 1
Yes, it seems I have to finish practicing at night.☺
27th Jan 2019, 6:42 PM
Solo
Solo - avatar
+ 1
saif Get used to tiny bugs like this, if you want a career in coding!! 😁
27th Jan 2019, 10:53 PM
James
James - avatar
0
You need to activate the "update ()" function, for example by setting the button: <button onclick="update()">right</button>
26th Jan 2019, 11:37 PM
Solo
Solo - avatar
0
Put something like this at the end of your script. The duration parameter is in milliseconds. setInterval(update, 100);
26th Jan 2019, 11:59 PM
James
James - avatar
0
i actually have the same one in the draw function
27th Jan 2019, 9:57 AM
saif Zak
saif Zak - avatar
0
James why should i , i mean its right there in the draw function which is loaded right when the program runs, that and i tried it and no difference in the results is seen
27th Jan 2019, 1:00 PM
saif Zak
saif Zak - avatar