Design comparison
Solution retrospective
As I'm still very new to JavaScript, everything has been very difficult so far, I don't know what it would be like without the chat, or other people's solutions, because even the documentation is difficult to understand, but I know that everything is constant and that all this It's going to get into my head at some point
What challenges did you encounter, and how did you overcome them?*the whole JavaScript issue
I always put it on chatGPT and asked him to explain it to me line by line and why, I always try to use AI to teach me and not do it for me*
What specific areas of your project would you like help with?If anyone had feedback on my code or even a tip on how to better learn JavaScript, I would be very grateful!
Community feedback
- @MahmoodHashemPosted 5 months ago
Hello,
Congratulations on successfully completing your challenge.
Your project is impressive, with clean and cool code.
I have some suggestions to further improve it:
- The FAQ section should behave like an accordion, where opening one question hides the others. You can achieve this by querying all the paragraphs and using conditional logic in a foreach loop to hide or show them.
Here is the updated version of your code, where the answer paragraphs have a class added to hide them:
document.addEventListener("DOMContentLoaded", function() { const buttons = document.querySelectorAll(".toggle-button"); const paragraphs = document.querySelectorAll(".question-answer"); buttons.forEach((button, index) => { button.addEventListener("click", function() { paragraphs.forEach((p, i) => { if (i === index) { p.classList.toggle('hide'); button.src = p.classList.contains('hide') ? './assets/images/icon-plus.svg' : './assets/images/icon-minus.svg'; } else { p.classList.add('hide'); buttons[i].src = './assets/images/icon-plus.svg'; } }); }); }); });
Keep up the hard work
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord