Design comparison
SolutionDesign
Solution retrospective
My questions are:
- How do I round the result correctly? For example, if you add 0.1 and 0.2 you get 0.3000000000000000004. How do I get 0.3?
- When switching the theme on a mobile device, the radio buttons and pseudo elements on the switch are highlighted for a moment. How can this be fixed?
Community feedback
- @barryhannaPosted over 1 year ago
Hi Oleg,
to round the number you can use the
toFixed
method.0.3000000000000000004.toFixed(1)
Will round it to 0.3
I hope this helps.
Here's the MDN docs for toFixed:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
0
Please log in to post a comment
Log in with GitHubJoin 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