This WOD (Invoice1) involved creating a sales receipt for a sale with at least five different products, using JavaScript variables, expressions, and dynamic calculations. Here, I’ll discuss what went well, what presented challenges, my preparation strategy, and improvements for future WODs.
For details on Invoice 1, you can find it on Dr. Port’s GitHub repository here
Performing WOD 5.1 wasn’t that difficult and was very enlightening. Here’s what worked well and what presented challenges during the exercise.
Product Data Setup: Creating variables for each product and calculating their extended prices based on quantity and price was relatively straightforward. This allowed for easy customization of the products.
Calculations: The calculations for subtotal, sales tax, and total were accurate, thanks to the straightforward math operations in JavaScript.
Table Generation (Option 2): Using the insertRow method to dynamically add rows to the table worked well. It kept the code organized and made it easier to update if more products were added.
Debugging: Debugging took some time, especially when I encountered issues with case sensitivity in JavaScript properties like innerHTML. Typographical errors can easily disrupt the functionality.
HTML Integration: Initially, I tried to generate HTML rows using document.write(), which led to confusion in managing the layout. Switching to using insertRow (Option 2) improved the readability of the code.
To prepare for this WOD, I followed a similar strategy to previous WODs:
Understanding Requirements: I thoroughly read and understood the WOD requirements to ensure I knew what was expected.
Conceptualizing the Solution: I outlined a plan for the task, breaking it down into smaller steps, such as setting up product variables and calculating prices.
Code Structure: I created a structured script, clearly separating sections for product data, calculations, table generation, and displaying results.
Testing Incrementally: I tested each part of the code incrementally as I added functionality. This approach helped catch and resolve issues early.
Error Handling: Implementing better error handling and validation mechanisms could enhance the code’s robustness.
Code Reusability: Consider refactoring the code to make it more modular and reusable. For instance, creating functions for calculations and table generation could make it easier to maintain.
Testing Strategy: Exploring testing frameworks and methodologies could help identify and resolve issues more efficiently.
Documentation: Adding detailed comments and documentation to the code can improve its readability and make it easier for others to understand and modify.
In preparation for future WODs, I plan to:
Practice Regularly: Continuously practicing JavaScript and HTML coding will help solidify my skills and confidence.
Explore Debugging Tools: Exploring debugging tools within browsers can make it easier to identify and resolve issues quickly.
Peer Interaction: Engaging with classmates and participating in group discussions can provide diverse insights and collaborative problem-solving opportunities.