0

Why do i get errors when I separate the scripts in Code Playground?

Here is my code: https://code.sololearn.com/WRd2oe54y92G/?ref=app

9th Oct 2017, 3:04 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
3 odpowiedzi
+ 16
Try window.onload = function delay(){ // your entire Javascript code here } //this is because your Javascript loads before your document & causes issues like undefined. //hence delay your Javascript execution till doc load
9th Oct 2017, 6:07 AM
Lord Krishna
Lord Krishna - avatar
+ 2
@Lord Krishna, thanks. window.onload works as well as setTimeout. But when I do that, the onclick value in html becomes undefined.
9th Oct 2017, 10:26 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
Wow thanks..
11th Oct 2017, 12:29 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar