QUESTION IMAGE
Question
jump to level 1
assign hourspassed with the number of hours passed since facebooks website launched and today.
note:
- use gettime () to return milliseconds.
- convert the milliseconds between currentdate and interestingdate to hours.
- 1000 milliseconds are in a second, 60 seconds in a minute, and 60 minutes in an hour.
1 let interestingevents = {
2 // reminder for month: 0 = jan, 1 = feb, 2 = mar, etc.
3 \long distance telegraph\: new date(1844, 4, 24),
4 \first telephone call\: new date(1876, 2, 10),
5 \microsoft founded\: new date(1975, 3, 4),
6 \world wide web born\: new date(1989, 2, 1),
7 \google founded\: new date(1998, 8, 4),
8 \facebook website launch\: new date(2004, 1, 4)
9 };
10 // code also tested using date of first telephone call
11 let currentdate = new date();
12 let interestingdate = interestingevents\facebook website launch\;
13 let hourspassed = 0;
14
15 / your solution goes here /
16
Step1: Calculate the difference in milliseconds
The difference in milliseconds between currentDate and interestingDate is currentDate.getTime() - interestingDate.getTime().
Step2: Convert milliseconds to hours
Since \(1\) hour \(= 60\times60\times1000 = 3600000\) milliseconds. So the number of hours passed is \((currentDate.getTime() - interestingDate.getTime())/3600000\).
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
let hoursPassed = (currentDate.getTime() - interestingDate.getTime()) / 3600000;