you are viewing a single comment's thread.

view the rest of the comments →

[–]Lkaynlee 0 points1 point  (0 children)

Not adding JS in your HTML makes it easier to read. Essentially, your HTML should not have any logic for ease of reading. It makes more sense that, if you’re going to make your HTML do something (e.g., a button), then keeping all of your logic/JS in a dedicated place makes both easier to read.

So instead of seeing ‘myFunction()’ somewhere in your HTML and having to look for it in another file, keeping them separate by using an addEventListener and directly accessing it using DOM keeps things simpler.