+ 18

Why my loop does not work ?

I want this loop to work inside the <h3>, how could i do that ?! https://code.sololearn.com/W256rgje7B7h/?ref=app

28th Feb 2019, 11:23 AM
Bono
Bono - avatar
8 Réponses
+ 14
Gordon & Hatsy Rei thanks, i will follow your tips 👍
28th Feb 2019, 12:27 PM
Bono
Bono - avatar
+ 11
Your script is loading before DOM is loaded. Wrap your JS code in onload function. window.onload = function() { // your JS code here } Also, you cannot incremented a HTML element using ++ in your loop. You might want to get the innerHTML value instead.
28th Feb 2019, 11:34 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
<del>This question has been asked many times, please use search function, Bono</del>🤣😂🤣😂🤣😂🤣 kidding A bit supplements to the answers above: Sololearn js tab of web codes will be added to the end of head tag when compiled. So it will run before the body. There are several ways, either putting everything in window.onload as Hasty Rei has suggested, or scripting a function in js tab (head), and later call it in end of body tag as Emma has demo A question that naturally arises is, which comes first? This code by Calvin best demonstrates the sequence of loading: https://code.sololearn.com/W8qiO41gHNfu/?ref=app
28th Feb 2019, 11:48 AM
Gordon
Gordon - avatar
+ 3
https://code.sololearn.com/WuKbLT0vAp3d/?ref=app
28th Feb 2019, 9:38 PM
Daniel Cooper
Daniel Cooper - avatar
+ 3
Wait this question was already answered Thanks phone/sololearn glitch
28th Feb 2019, 9:38 PM
Daniel Cooper
Daniel Cooper - avatar
+ 2
Hi, Bono! I "played" a little with your counter. See this: https://code.sololearn.com/Wuhz7RUEJkL6
28th Feb 2019, 9:50 PM
Rafael S Valle
Rafael S Valle - avatar
0
"The limit exceeded"?
10th Mar 2019, 4:38 PM
Олег