Skip to content
Submitted about 1 year ago

Calculator app, using Next 16, Typescript and tailwind css

LVL 2
@tundeloper
A solution to the Calculator app challenge

Solution retrospective


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

I’m most proud of completing all the core calculator functionality—including chained operations, deleting input, and resetting the state—while keeping the UI consistent across different screen sizes. I’m also proud of implementing multiple themes cleanly and ensuring they switch smoothly without breaking the layout.

If I were to do it differently next time, I would structure my JavaScript logic in a more modular way to make the code easier to maintain and extend. I’d also set up more deliberate accessibility features from the beginning, such as better focus states and ARIA labels.

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

One major challenge was handling the calculator logic, especially ensuring operations worked in the correct sequence and managing edge cases like decimals, consecutive operators, and division by zero. I solved this by breaking down the logic into smaller functions and carefully managing the calculator’s internal state.

Another challenge was getting the CSS Grid layout to match the design across different screen sizes. I used custom grid-template-areas and responsive units to maintain the structure. The theme-switching logic was also tricky at first because I needed to sync the UI state with localStorage. I overcame this by creating a dedicated theme-handling function that updates both the DOM and the saved preference.

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

The structure and cleanliness of my JavaScript logic (especially the operation-handling functions).

Accessibility, including keyboard support and ARIA labeling.

Making the theme-switching code more scalable in case I want to add more themes later.

Best practices for handling responsive typography and spacing.

Code
Loading...

Please log in to post a comment

Log in

Community feedback

No feedback yet. Be the first to give feedback on Babatunde’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