Code Refactoring JavaScript
Hello, I was practicing dom and trying to use functions to reduce amount of code, this is what i did first:
6 Replies
Well
document.querySelector(".link");
is only going to find the FIRST .link
element, not any of the others.
Were you trying to find more than one?this the code now
i change the class name to mark all, because "link" was a confusing
what do you think about the change or how would change it
can you understand now? sorry for the class name 😅
Frankly, I like the way it was as it uses foreach in a really good way.
thanks bro
Everything was grouped very cleanly in those two foreach loops making the code easier to read and understand.