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
4 ответов
+ 3
Your code is running prior to the body being loaded. Use window.onload to postpone running.
window.onload = function() {
//existing JS code
}
+ 1
@John Wells thank you so much. It's working well now.
😃
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
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.