0

Please why is the code not working. Please help. Thanks!

I intend to create a rectangle using canvas. https://code.sololearn.com/WmL9o9KcOioE/?ref=app

12th Feb 2018, 1:48 PM
Abiola
Abiola - avatar
4 Respuestas
+ 3
Your code is running prior to the body being loaded. Use window.onload to postpone running. window.onload = function() { //existing JS code }
12th Feb 2018, 1:58 PM
John Wells
John Wells - avatar
+ 1
@John Wells thank you so much. It's working well now. 😃
12th Feb 2018, 2:59 PM
Abiola
Abiola - avatar
0
For you to create a rectangle, width and height must be of different sizes. Is will work if you put your JavaScript inside <script></script> tags in your HTML code, like here: https://code.sololearn.com/W90Cdlj29F9d
12th Feb 2018, 1:59 PM
Fabrício Lombardi Ribeiro
Fabrício Lombardi Ribeiro - avatar
0
@Fabrício I understand what you're saying, but they said the better practice is to keep scripts out of the html documents. That's what I am trying to stick to.
12th Feb 2018, 3:02 PM
Abiola
Abiola - avatar