[SOLVED] What i did wrong in my js code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

[SOLVED] What i did wrong in my js code?

Box can move normal from left to right and from top to bottom but cant from right to left and bottom to top. I wanna make box go in circle. How to fix this. https://code.sololearn.com/WCLmdmWLpLVT/?ref=app

9th Jul 2019, 11:29 PM
PanicS
PanicS - avatar
3 Answers
+ 1
There are several ways, but the easiest is to change the value of right and bottom variables to 150 and the if statements to ... if (right <= 0) { if (bottom <= 0) { ... } } ...
10th Jul 2019, 12:06 AM
Agent_I
Agent_I - avatar
+ 5
You could ditectly check the condition from the actual box.style.top/left location https://code.sololearn.com/WASVXpgs3lip/?ref=app
10th Jul 2019, 4:16 AM
Calviղ
Calviղ - avatar
+ 5
Thank you both 😊
10th Jul 2019, 6:41 AM
PanicS
PanicS - avatar