Design comparison
Solution retrospective
Tried to make the project as close to how an acutal tip calculator would work.
Any simpler ways to do the js?
Community feedback
- @dev-eliPosted about 2 years ago
Basically for the JS I just created event listeners for all the buttons or inputs, and every time one of them changed, I would attempt to calculate it in a separate function. If I could calculate it, great, if not, I would just keep the results at $0.00. I can include a link to my github repo and you can check out the script.js file there: https://github.com/dev-eli/tip-splitter/blob/main/script.js
My code isn't as readable as yours I think but it might be simpler, up to you to decide.
I liked how you included the form validation saying numbers only,I thought that was a nice touch. I accidentally restricted the input of non numbers by setting the value of the element to the value of the event and that would remove all the non numbers, which kind of makes it confusing.
Anyway, I hope this helps.
Best, Eli
1@tbrownleePosted about 2 years ago@dev-eli sorry for the late response!
I like the logic of your project.
Yeah I thought saying "Numbers only" made more sense than "Can't be zero."
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