Javascript Stopwatch Continued
January 04, 2022 by Michael
I took a couple of weeks off from coding to recharge and be with loved ones. I feel more refreshed and ready to learn as much as possible in 2022!
Today I completed the JavaScript stopwatch project.
This project was completed using if statements and can be viewed on GitHub.
I also had a pairing session with my mentor and we were able to review the code and format it so that there were fewer mutable global variables present. He explained the importance of avoiding these variables as it can cause issues later on with more complex programs.
By using functions, we were able to achieve this desired format. I will have to keep using this practice moving forward with other projects.
We also discovered that at the end of the program, there was no code to fully reset the stopwatch back to the starting point, so we added an extra line of code to set the stopwatch back to the starting place. We walked through the process of troubleshooting this by creating a state transition table and walking through each step of the Start/Stop and Reset buttons. This helped to isolate the issue.