Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Accordion FAQ card with JS and Sass

#bem#gulp#sass/scss#accessibility
Danilo Blasโ€ข 6,300

@Sdann26

Desktop design screenshot for the FAQ accordion card coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


This is my first project using Javascript, I would like to get your feedback on its implementation in the project and what could be improved.

Community feedback

Vanza Setiaโ€ข 27,855

@vanzasetia

Posted

๐Ÿ‘‹ Hi Danilo!

๐ŸŽ‰ Congratulations on finishing your first JavaScript challenge! I have some feedback on this solution:

  • Accessibility
    • Currently, the accordions are not accessible with keyboard and screen reader. I would recommend using details and summary tags instead of div.
    • Keep in mind that, any elements that have :hover or :active states are commonly interactive elements (button, details, input, a, etc).
    • Create a custom :focus-visible styling to any interactive elements (button, links, input, textarea). This will make the users can navigate this website using keyboard (Tab) easily.
    • For any decorative images, each img tag should have empty alt="" and aria-hidden="true" attributes to make all web assistive technologies such as screen reader ignore those images. In this case, all images are decorative only.
  • JavaScript
    • I would recommend using forEach instead of for loop. forEach will make you write less code since with querySelectorAll(), you can directly use forEach without making it as an array.
const questions = document.querySelectorAll(".FAQ-accordion__question");

const doSomething = (e) => {
  // some code
}

questions.forEach(question => question.addEventListener("click", doSomething))
  • Also, separate the function from the addEventListener. It's going to make your code much easier to understand.

That's it! Hopefully, this is helpful!

Marked as helpful

2

Danilo Blasโ€ข 6,300

@Sdann26

Posted

@vanzasetia, interesting!!! Thank you very much for your recommendations, I will keep them in mind from now on. :D

0
Danilo Blasโ€ข 6,300

@Sdann26

Posted

Update solution :D!!!

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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