Karim• 590
@Galielo-App
Posted
Hello, Sebastian!
Awesome build, just a few things about your js:
- For loops are ok, but in javascript we really like using
forEach
andmap
, look at this example:
//your for loop
for (i = 0; i < radios.length; i++) {
radios[i].addEventListener("change", openPledge);
}
//with forEach
radios.forEach(radio => radio.addEventListener("change", openPledge))
Trust me, this will make your code easier to write, read and maintain.
- You don't need a
openMenu()
and acloseMenu()
, u can usetoggle
and have a compacted, quality code. Look:
function handleMenu() {
document.querySelector(".nav-list").classList.**toggle**("open");
document.body.classList.**toggle**("overlay");
mobileMenu.childNodes[0].src = "./images/icon-close-menu.svg" ? "./images/icon-hamburger.svg" : "./images/icon-close-menu.svg";
}
For any question or suggestion feel free to ask :)
Upvote my comment if I was helpful and happy coding :)
1
Sebastian Söderström• 160
@bastiman85
Posted
Thanks a lot! I will look into these.
0