Design comparison
Solution retrospective
(Disregard the lack of accessibility, I was mostly interested in the JS) I would love to know how to clean up my code, specifically how I could have simplified the JavaScript! I'm new to it and thought this would be a great way to reinforce what I had learned and while I got it working I know it's probably overkill!
Thanks ahead of time
Community feedback
- @Dullahan83Posted 10 months ago
Hello :) There is not much you could have done with a static version except create a function that takes expander, panel, panelExpanded and img and call it for every accordion there is. That would avoid repeating all the block and just call the fonction n Times with the different params
But i would suggest you to look either into design pattern or object oriented programming. Mostly to avoid code repetition, one method create the accordion with question and answer as parameters. That would make it go from static to dynamic and it's more interesting :)
But your solution works, and it's the most important.
Marked as helpful1@jcad57Posted 10 months ago@Dullahan83 Oh gotcha! Thank you! I'm in a JavaScript course right now and I think object-oriented is coming up soon so I'll look forward to that! Cheers
1@Dullahan83Posted 10 months ago@jcad57 I did the challenge in the meantime with oop and dom manipulation if you want an example of what it can be. Of course this is just my implementation of it and it can be done in many ways.
Happy Coding and good luck in your javascript course :)
1
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