Code Playground | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Code Playground

Personally, I don't really like writing JavaScript inside HTML. I like it in it's separate file. But for some reason, the Sololearn Code Playground for web really has issues against this. When writing JavaScript separately from the HTML there are a lot of errors. But when I write the same code in HTML inside <script> tags, it works like a charm, and this really ticks me off. What causes this?

17th May 2020, 7:18 PM
Thomas Sankara
Thomas Sankara - avatar
4 Answers
+ 3
This may shine some extra light on what is the cause of your problems. https://code.sololearn.com/WcdoF4PGPyDC/#html
17th May 2020, 8:18 PM
ODLNT
ODLNT - avatar
+ 2
Just an exceeding solution is : window.onload = () => { // all your javascript code goes here }
17th May 2020, 7:56 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
17th May 2020, 7:34 PM
Sebastian Pacurar
Sebastian Pacurar - avatar
0
Ookay 🤔. Now I understand it. Thanks
17th May 2020, 8:24 PM
Thomas Sankara
Thomas Sankara - avatar