+ 2

Whats wrong with this Code?

DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <div id="container"> <div id="box"> </div> </div> <script>function move() { if(pos >= 150) { clearInterval(t); } else { pos += 1; box.style.left = pos+'px'; } move(); </script> <button id="btn"onclick=move() > Nochmal </button> </body> </html> SoloLearn throws an error at line 18 of the code(the closing script block). Please help me!

8th Sep 2020, 8:24 PM
Mir Egal
Mir Egal - avatar
4 Réponses
+ 4
You missed a } for the move function and also pos is not defined.
8th Sep 2020, 8:27 PM
RKK
RKK - avatar
+ 3
Thanks
8th Sep 2020, 8:28 PM
Mir Egal
Mir Egal - avatar
+ 2
You forgot to put the closing curly bracket for move function
8th Sep 2020, 8:26 PM
Abhay
Abhay - avatar
+ 2
1. Close the curly bracket 2. function pos not defined 3. It is highly reccomended to change line 1 to <! doctype html> Bitteschön
8th Sep 2020, 8:52 PM
Galaxy-Coding (inactive)
Galaxy-Coding (inactive) - avatar