+ 4

{solved}Plz I need help with my code.

I passed the variable "rotateDeg" in the argument of setRotationInterval, then I incremented by 1 every .008seconds from 0 in the setInterval. But when I click a button to run the function for the box to rotate, the "rotateDeg" variable does not increment. How can I get past this problem? It rotates when I press the buttons multiple times but I want the box to rotate itself when I press any button once. https://code.sololearn.com/W9Jlx9HJqYL5/?ref=app

12th Nov 2020, 8:56 AM
Fasasi Sherif
Fasasi Sherif - avatar
6 odpowiedzi
+ 4
JaScript Thanks very much. Though I've gotten it. I used another method.
12th Nov 2020, 12:02 PM
Fasasi Sherif
Fasasi Sherif - avatar
+ 4
Cool. One thing only, it would be interesting, if you could click second time the same button to stop the rotation. Do you like this challenge to code?
12th Nov 2020, 3:42 PM
JaScript
JaScript - avatar
+ 4
Thank you for your suggestion. I love it. I appreciate it. I'll implement it soon. Well, I think I like some challenging codes.
12th Nov 2020, 4:44 PM
Fasasi Sherif
Fasasi Sherif - avatar
+ 3
let rotation; let rotateDeg = 0; variables should be global.
12th Nov 2020, 11:59 AM
JaScript
JaScript - avatar
+ 3
No problem, your welcome.
12th Nov 2020, 4:54 PM
JaScript
JaScript - avatar