0
Why does this code not work properly?
I tried to manipulate the code from Sololearn, so that the box not just goes to the right. Why moves it just to the right and left and not down and up? What fo I have to fix? https://code.sololearn.com/W186hKm6aj9d/?ref=app
6 Respostas
+ 5
Your mistake is in these lines:
box.style.top = posy+'py';
The string at end of the property value is the css unit you want to append to the numerical value... and there's no 'py' css unit, just 'px', which stand for 'pixels' ;P
(you need to correct it in both function using 'top' css style attribute ^^)
+ 4
You only invoke the function movex... So in the interval t you should use this:
var t = setInterval(function() {
movex();
movey();
}, 10);
O and px is a unit, it stands for pixel so change the part with py back to px and it should work
+ 4
@The Coding Sloth:
The setInterval() method is correctly used in this code, if the purpose is to chain the four moves one after each other ;)
+ 4
I had no doubt on that :D
+ 1
Ok thanks
I thought px stands for "position of x" and forgot the "".
0
Now it works.