0
Why does it fail when it is lost?
2 Respostas
+ 1
Code works fine but that error is generated when trying to get the body element that doesn't exist yet , which is because sololearn places Javascript in head tag ,so script is executed first and HTML is loaded afterwards .
What you can do to prevent that is letting HTML dom load first and then execute Javascript,so to do that, place your js code inside the following function (mostly the one which is accessing dom elements) :
window.onload=function() {
//js code goes here
}
0
onload = () => play(random);