Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Milestone 1 Programming Report

IT 505 Core Technologies

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

crucial for calculating the time remaining until the upgrade.

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

obtain the millisecond representation of each date. By subtracting `today.getTime()` from

`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

representing the remaining days.


The final component involves displaying the message to the employees. The code uses

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

displayed via an OS upgrade message to employees. We examined five essential components of

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.

GROUP 1 Initial Upgrade Date:


GROUP 2 Upgrade Date:
GROUP 3 Upgrade Date

GROUP 4 Upgrade Date:


GROUP 5 Upgrade Date:

You might also like