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
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) {
...
}
}
...
+ 5
You could ditectly check the condition from the actual box.style.top/left location
https://code.sololearn.com/WASVXpgs3lip/?ref=app
+ 5
Thank you both 😊