Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Calculator app - theme 3

Garf228 90

@Garf228

Desktop design screenshot for the Calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

I didn't implement the theme selector, but I figured out all of the JS logic myself which I am proud of.

Community feedback

P
Jake Godsall 1,390

@jakegodsall

Posted

Hi 👋

Great work on this!

One thing I noticed is that when the calculator displays very large numbers the number will overflow off the screen.

In terms of solutions, there are a few.

You could introduce a scrollbar to see the full number, dynamically reduce the font-size as the number reaches 16 digits (currently the full width of the calculator). The second option looking something like this:

function adjustFontSizeForDisplay(number) {
    const displayElement = document.getElementById('calc-output');
    let fontSize = 56; // Default font size in pixels
    const maxLength = 16; // Max length of number before adjusting font size

    if (number.toString().length > maxLength) {
        const overflowLength = number.toString().length - maxLength;
        fontSize -= overflowLength * 2; // Decrease font size based on overflow length
    }

    displayElement.style.fontSize = `${fontSize}px`;
}

You could then apply this function everytime the value in the calc-output changes.

Hope this helps at all 😀

Marked as helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

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