Milestone 1 Programming Report
Milestone 1 Programming Report
Melissa Lamica
July16, 2023
Modifying JavaScript Code for OS Upgrade Message
In this report, we will discuss the modifications made to the provided JavaScript code to
display a new message to employees when they open their web browsers. The objective is to
inform them about the upcoming operating system (OS) upgrade. We will describe five key
components of the code and explain their roles in this specific programming modification.
Variables are used to store and manipulate data in JavaScript. In the modified code, two
variables are used: `today` and `UpgradeDay`. The `today` variable holds the current date,
obtained using the `new Date()` constructor. The `UpgradeDay` variable stores the specific date
of the OS upgrade, initialized with a predefined date ("March 1, 2023"). These variables are
The code utilizes the variables `today` and `UpgradeDay` to calculate the time difference
in milliseconds between the current date and the upgrade date. It uses the `getTime()` method to
`UpgradeDay.getTime()`, the code determines the time remaining until the OS upgrade.
To convert the time difference from milliseconds to days, the code employs the variable
`msPerDay`. It represents the number of milliseconds in one day (24 hours * 60 minutes * 60
seconds * 1000 milliseconds). The code then divides the time difference by `msPerDay` to obtain
the number of days remaining until the upgrade. The result is stored in the variable `days`.
To ensure that the number of days remaining is displayed as an integer, the code uses the
`Math.floor()` function. It rounds down the value of `days` to the nearest integer, stored in the
variable `daysLeft`. This prevents decimal values in the output and provides a whole number
the `document.write()` method to write HTML content dynamically. It combines the calculated
`daysLeft` value with HTML tags to create the output message. The message is then displayed on
the webpage when the script is executed. The HTML tags used, such as `<br>`, `<h4>`, and
`<p>`, format the output message for better readability and visual appeal.
As you can see, the discussed modifications made to the provided JavaScript code are
the code: variables for storing dates, date calculation for determining the time remaining,
mathematical calculations for converting milliseconds to days, the floor function for rounding
down to whole numbers, and the output display using the `document.write()` method. These
components work together to exhibit a dynamic message, providing employees with information
about the impending OS upgrade when they open their web browsers.
The following screenshots begin with the initial upgrade date labeled as Groups 1 through Group
5.