Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

3 themed calculator

tailwind-css
Cesar D.•400
@ThatDevDiaz
A solution to the Calculator app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Could use some help please.

Created the 3 themed calculator utilizing flex grid to practice. I used custom colors to practice originality and customization. The themes are toggle using javascript.

I'm posting the incomplete javascript functionality in hopes I can get some pointers. Here's my issue:

I cannot for the life of me figure out how to store the calculator's input data to then be used in the calculation. For example, I will create onclick event handlers for the buttons, but the event handler function cannot return outside of the event handler so I can't store it in an array or variable or whatever i'm trying to store it in. If I can't store it outside the button's functionality, how the heck do I calculate? Maybe there's a perspective i'm not seeing.

So I tried manipulating the span and storing the input into the span, but when I click another event handler it overrides it. Maybe this isn't the right approach. I'm honestly stuck. I watch tutorials but they all approach it in different ways and I'm just trying to do it my own way without just copy pasting their code.

I'm so close to giving up on this calculator. Maybe I wasn't ready for it.

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 Cesar D.'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