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

Faq-accordion

@Caleb-Abuul

Desktop design screenshot for the FAQ accordion coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

I wrote the code with little or no assistance from outside. I used my initiative and problem-solving skills to put the solution together.

What challenges did you encounter, and how did you overcome them?

During the challenge I had a hard time trying to add an event listener to the tiles such that when clicked on, it would reveal its content. So I wound up giving all the tiles the same class name and then accessing them from JavaScript via className. This returned a collection which I changed into an array using the spread [...arr] operator. Using the forEach() method, I added an event listener to each tile such that when any tile is clicked, it closes all other tiles and reveal only its content.

What specific areas of your project would you like help with?

My biggest challenge was making the tiles in the accordion close when clicked on a second time. So I used a loop to add a hide class to all the tiles and then toggle the current tile that is clicked on open to reveal its content and change the icon from a plus sign + to a minus sign -. However, I wanted the tile to close, if open, upon a second click, but to no avail. I would appreciate it if you could share with me how I can go about closing a tile that is been open already when it is being clicked on a second time.

Community feedback

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