+ 5

Help with Playground, gives me an error when I execute my code?

Hi! I am trying to display a list of strings stored inside an array, the code works on code editor like CodeRunner2, Atom, and when I load the html on chrome and safari it works too, I try executing the code on jsfiddle same there, it working but here I'm getting this error : TypeError: null is not an object (evaluating 'dsp.innerHTML = list') Line: 10 here is the link to the code, check if I'm doing something wrong https://code.sololearn.com/WYSEJr7k12KM

16th Jan 2018, 8:17 AM
StoneCoder🇬🇦
StoneCoder🇬🇦 - avatar
2 odpowiedzi
+ 7
Your code is showing an error because Javascript is loading before the body.To kill this error wrap your whole js code with this. window.onload = function(){ //whole js goes here. }
16th Jan 2018, 9:56 AM
Ranjan Bagri
Ranjan Bagri - avatar
+ 3
thank you, it's working now
16th Jan 2018, 11:48 AM
StoneCoder🇬🇦
StoneCoder🇬🇦 - avatar