Design comparison
Solution retrospective
How did everyone deal with several inputs leading to one solution without a submit button? I found it difficult to ensure that the solution didn't calculate or render until all of the inputs were complete.
I also felt like my code was very repetitive. Whats you're favorite method of refactoring to make your code DRY?
Community feedback
- @emjogalePosted over 2 years ago
Hi Sara, well done on your project - the layout looks great! Regarding your question about several inputs leading to one solution without a submit button - the way I tackled this problem was by just attaching event listeners to each of the tip amount buttons - then you only need one function to calculate the sum. This function would get the value of the button clicked and at the same time what the value of the bill and number of people inputs are. This eliminates the need for attaching an event listener to the other buttons and also means that no calculations can be made before the other inputs have been filled in. Also regarding your html - I'm sure you have read the report - but do note that you can't give more than one element the same id - you have already given your buttons the class of "per-btn" so there is no need for you to give them this as an id as well. I hope this is of help!
1@skuenziPosted over 2 years ago@emjogale thanks for your response! I'm sure I had some brilliant reason for assigning the same id to five buttons, but I can't for the life of me remember what it is! Thanks for pointing it out!
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