Thanks for checking out this front-end coding challenge.
- HTML
- CSS / SASS
- Vanilla Javascript
- Google for research :]
- The first time I created the logic with javascript, I implemented a separate button that allowed the user to input all information and calculate on click. I was unable to get the click event to trigger on mobile (even though it worked correctly on desktop).
- I solved the above issue by restructuring the logic in the JS file. I separated out the app into 4 different event listeners:
- Bill Value on input change
- Tip Value on click event (off the pre-set options)
- Custom Tip Value on input change
- Number of people on input change
- I created a 'calculateTip' function that is being run every time any of the above event listeners gets triggered.
- I ran into the issue of creating arrow functions and calling those methods before they were initialized. This was fixed by changing arrow functions to regular function expressions.
- Need to still learn the nuances of when to use async/await. It doesn't seem relevant here because I'm not having to fetch any data from APIs.
- Need to learn how to better organize logic - instead of writing it out as I go. Better to plan first, then write code.