HELP 2 [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

HELP 2 [SOLVED]

I need help the red ball won't jump anymore! !! https://code.sololearn.com/W1RQmP0gtLHT? ref=app

27th Nov 2022, 10:42 AM
MikroMick
MikroMick - avatar
2 Answers
+ 3
Seems that btn.onclick does not work. Added onclick attribute on the button in the html to fire the and edited the js a bit. https://code.sololearn.com/W9Ne0F6oAsp7/?ref=app
27th Nov 2022, 2:38 PM
Lochard
Lochard - avatar
+ 2
With your code as is, as of this reply, the main problem is that nowhere within your js code do you call/invoke draw(). But even if you did call/invoke draw() an error message would appear "ReferenceError: context is not defined", letting you know of the other issue. This error will occur because the variable context is local to the onload handler() and draw() is outside the onload handler(). I suggest moving draw() inside of the onload handler(). You should call/invoke draw() inside of the onload handler() as well. Btw, why do you need three onclick handlers()? You are overwriting the onclick handler() so the last one is actually invoked. https://code.sololearn.com/WFo9bH1T9B5D/?ref=app
27th Nov 2022, 5:16 PM
ODLNT
ODLNT - avatar