Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 10 months ago

added functionality to a button to toggle between two values.

Obiwumma•170
@Obiwumma
A solution to the Article preview component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


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

I'm proud of the fact that I took my time on this project. Struggled through the functionality

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

I encountered multiple issues, such as trying to make different functions run at different screen sizes. To solve this, I implemented the window.matchMedia() method, which allows JavaScript to dynamically respond to screen size changes, similar to CSS media queries.

Another issue was that my code worked well in Chrome DevTools but refused to work in my main browser window. To fix this, I wrapped my entire script in "DOMContentLoaded" to ensure it runs only after the HTML document has fully loaded. I also specified the screen size precisely.

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

This is my first JavaScript challenge in a long time. My code writing style is amateur. There are probably better ways I could do this so I'm open to all opinions

Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Obiwumma's solution.

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

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner
  • Use cases

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License