Any Help on why the function doesn't work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Any Help on why the function doesn't work

If i press the button the rect does not show https://code.sololearn.com/WXD6d6IT5BF8/?ref=app

11th Jan 2019, 10:56 AM
Harshey's
Harshey's - avatar
4 Answers
+ 2
Because draw function is not global. It is local to that anonymous function you assigned to window.onload. Put that code in a script tag in html part(remove window.onload) or Use addEventListener.
11th Jan 2019, 11:22 AM
Prathamesh Sawant
Prathamesh Sawant - avatar
+ 8
11th Jan 2019, 11:24 AM
Bono
Bono - avatar
11th Jan 2019, 11:26 AM
Asgar Ali
Asgar Ali - avatar
+ 1
Thanks for the help
11th Jan 2019, 11:28 AM
Harshey's
Harshey's - avatar