Skip to main content

Timeline for Simple JavaScript tip calculator

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Sep 30, 2018 at 14:28 comment added Eric Nguyen Thanks again Stexxe! Although I could not find your contact, I have posted a new project for review which I've implemented a few things I've learned from you on this project. Would be great to get your feedback --> codereview.stackexchange.com/questions/204630/…
Sep 28, 2018 at 8:08 comment added Stexxe I think you also want to know how I would program this from scratch. You can find contacts in my profile, so we can chat and I will explain my approach to program this kind of problems. I hope this comment doesn't break any rules of service.
Sep 28, 2018 at 7:43 comment added Stexxe There are two problems with method update. 1) You need to call it few times and pass same arguments for input and output (billInput and tipSuggestion). 2) It's difficult to remember the order of parameters from function name. So I decided to save those arguments in closure to solve problem 1) and partially solve problem 2). In method update you just need to pass percent, which is only one changing.
Sep 28, 2018 at 7:38 comment added Stexxe Ok. In each method you have code duplication. In each method you calculate some value. So, I decided to start from isolating calculation, because it's easy to start from model perspective. I created method calcTip(), which needs percent and bill amount (parameters) to calculate a tip. The same thing I did for forming a message by isolating it in the method getMessage(). That's it for model. The rest is DOM manipulations. To take input you need to have billInput, to output result - tipSuggestion, and also percent amount. So I made method update(input, output, percent)
Sep 27, 2018 at 20:44 comment added Eric Nguyen Stexxe - can you explain your mindset/approach when programming this? I understand your code but it's a lot harder to replicate from scratch.
Sep 27, 2018 at 5:36 vote accept Eric Nguyen
Sep 27, 2018 at 5:35 comment added Eric Nguyen Took me a while to fully understand as I had to figure out what closures are. A quick YT tutorial and I've learned something new; evidently it's very useful! Feel like I powered up one level in my JS journey. Thanks for this solution!
Sep 25, 2018 at 7:58 history answered Stexxe CC BY-SA 4.0