Submitted about 1 month ago
Article Preview Component | HTML5 - CSS - JS - BEM
@Marcod01
Design comparison
SolutionDesign
Solution retrospective
What challenges did you encounter, and how did you overcome them?
I encountered challenges with applying different javascript functions to the different screen sizes.
What specific areas of your project would you like help with?I would like help with my BEM notation as well as how I could've made the javascript more concise.
Community feedback
- @huyphan2210Posted about 1 month ago
Hi, @Marcod01
Good job on this challenge!
I have a suggestion for improvement:
- Your
toggleHidden
andresetStateOnResize
functions could be simplified. Instead of using this code:
if (shareContainer.classList.contains('hidden')) { shareContainer.classList.remove('hidden'); footerContainer.classList.add('hidden'); } else { shareContainer.classList.add('hidden'); footerContainer.classList.remove('hidden'); }
You can do this:
const isHidden = shareContainer.classList.contains('hidden'); shareContainer.classList.toggle('hidden', isHidden); footerContainer.classList.toggle('hidden', !isHidden);
The
toggle
method adds or removes a class based on the second argument, which helps reduce code duplication.You can apply the same approach to your other classes as well.
Hope this helps!
Marked as helpful0 - Your
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