+ 1
What is wrong with it
Canvas when I run the code it shows error in line 2. Can't find what is wrong in line 2. https://code.sololearn.com/WOcyZ1RyYCer/?ref=app
4 Antworten
+ 5
if you're following the sololearn game dev with JS course, you forgot to wrap it in window.onload. There are other solutions of course, but that's the one you're expected to be aware of.,
+ 2
The js code runs before DOM element creation, write your Javascript code in side a script tag at the end of html body tag.
+ 2
Yasin Rahnaward Mixing HTML and JS, despite possible, makes the code less organized. This makes things increasingly harder as code gets more complex. Even worse when versioning code.
Always prefer - and recommend - keeping each part of the code in its place.
0
Thanks so much for everyone