Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 month ago

Tip Calculator App HTML/CSS/JS

P
Kyle Mulqueen•400
@kmulqueen
A solution to the Tip calculator app 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 most proud of the accessibility improvements I made throughout the project. Starting with basic HTML and progressively enhancing it with proper ARIA attributes, focus management, and error handling created a calculator that's usable for everyone. The clean implementation of form validation with visual feedback is another highlight.

I'm also particularly proud of the error handling system that provides clear feedback without being intrusive, and the robust event handling that maintains consistent state across different user interactions.

Next time, I would plan my HTML structure with accessibility in mind from the start rather than refactoring later.

Additionally, I would implement a more modular JavaScript structure, potentially using small utility functions or even a simple state management pattern. Breaking the calculation logic into smaller, more testable functions would improve maintenance.

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

The biggest challenges were:

  1. Styling form inputs while maintaining accessibility: Creating custom styles for number inputs while keeping them fully accessible required several iterations.
  2. Focus states for compound elements: Getting the focus outline to wrap around both the icon and input field took experimentation with various CSS properties.
  3. Custom validation: Balancing HTML5 validation with custom JavaScript validation for better user experience was complex.
  4. Browser persistence issues: Handling the unexpected persistence of form state after page reload required understanding browser behavior and implementing explicit reset logic.
  5. Input validation timing: Determining when to validate inputs (on input vs. on change) to provide a smooth user experience without premature error messages.

I overcame these by breaking problems down into smaller pieces, researching specific solutions, and iteratively improving the implementation based on feedback. The page refresh issue in particular taught me the importance of explicitly controlling state initialization rather than relying on browser defaults.

What specific areas of your project would you like help with?
  • Testing strategy: Implementing unit tests for calculation functions to verify accuracy with edge cases like zero values and decimal precision

  • State management: Refactoring to a more structured approach using a central state object or module pattern instead of separate variables

  • Input validation: Enhancing error handling with more descriptive user feedback for different error conditions

  • Accessibility verification: Testing with actual screen readers to ensure ARIA implementations and dynamic updates work correctly

  • Browser compatibility: Ensuring consistent form behavior across different browsers, especially regarding form state persistence

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • RickyPWebDev•200
    @RickyPWebDev
    Posted about 1 month ago

    hey, just having a read through your JS code,

    there's a few areas you could refactor if you wanted to:

    The two functions showErrors and clearErrors can be put into 1 function.

    function toggleError(element, action, show = true) { const method = show ? 'add' : 'remove'; if (action === 'hidden') { element.classListshow ? 'remove' : 'add'; } else if (action === 'error-state') { element.classListmethod; } } Looking at your code I have realised ive not put in any logic for error handling.

    Marked as helpful

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
Frontend Mentor logo

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

Frontend Mentor

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

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

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub