markdown guide
 

There are a few places in your code that could have been written better.

  1. Don't target the element over and over again when it's always the same. Save the output of document.querySelector somewhere and use that.
  2. Don't use the var keyword for declaring variables, it has been deemed obsolete. Use let and const instead.
  3. Don't pass a string to setTimeout as it means an implicit eval(). Evaluating code from strings is bad. Use the name of the function just like a variable instead.
  4. Put the setTimeout inside the if block. You have created an endless loop of timeouts there.
  5. Don't use window.onload, it's an obsolete API. Use addEventListener instead.
 
Classic DEV Post from Apr 12

Tip for beginners: There's no such thing as "weird" in programming

Advice for beginners on problem solving and not giving up when working on programming problems.

weptim profile image
I love working with javascript

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

(You can also change font to sans serif, which a lot of folks prefer.) 💖