Module 4 Assignment
Module 4 Assignment
1. JavaScript If Else Condition
For this assignment, I created my own customized if-else condition using JavaScript. The goal was to display a message based on how many hours someone studied.
This script checks the value of studyHours and displays a different message depending on whether the condition is true or false. I chose this example because it felt relatable and easy to understand, and it helped me see how if-else statements can be used to make decisions in a program.
Reflection:
Creating the if-else condition was easier than I expected once I understood the logic behind it. The easiest part was deciding what condition to check and writing the messages that would display on the page. The harder part was making sure the syntax was correct, especially remembering where the curly braces go and how the if-else structure is supposed to be written.
2. The original code had an issue with the if-else statement structure. The problem was that the brackets were not placed correctly, which caused the script to break.
Here is the corrected version of the code:
.
Comments
Post a Comment