0

Why won't this code work on desktop at all ?

As of right now, I don't have a desktop, but for today, I wanted to see what my codes look like on desktop, and I looked this code on desktop and there is ' Uncought Type error'. It works perfectly on my phone. I don't know why it wouldn't work on desktop.? https://code.sololearn.com/WgHrAhVj2Y5Y/?ref=app

26th Jun 2019, 4:17 AM
Ginfio
Ginfio - avatar
5 ответов
+ 1
https://code.sololearn.com/W8uDFBaXz6rf/?ref=app
26th Jun 2019, 4:47 AM
Airree
Airree - avatar
+ 1
It doesn't work perfectly on your phone. You should try to remember this; but this is because the page hasn't loaded yet. To avoid this, you should put the variable declarations in the window.onload function.
26th Jun 2019, 4:27 AM
Airree
Airree - avatar
+ 1
Airree do I window.onload through the whole javascript or, just for the variables at the top? can you remind me how you do it again - is it window.onload = () => { javasceipt } is it like that ^ ?
26th Jun 2019, 4:30 AM
Ginfio
Ginfio - avatar
+ 1
It's not necessary to put the whole javascript in the code. The only thing you must do, is the variable declarations (also don't use any keyword, so they will have global scope)
26th Jun 2019, 4:33 AM
Airree
Airree - avatar
0
Airree , could you please tell me at what line i would place the closing tag of the window.onload (i assume opening starts at the top windo...{ clos?) because i put the closing at bottom, and couldn't find var..., also tried it before the first function, ' couldn't find variable' .? Thank you
26th Jun 2019, 4:43 AM
Ginfio
Ginfio - avatar