-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (36 loc) · 1.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// to get our day
function dayOfWeek(){ // i created a function dayOfWeek
let d = new Date(); // using the date method to return the current local time and I assigned that hat time value a variable name "d"
let currentDay = d.getUTCDay(); // inorder to get convert to the date to a UTC standard I created another variable and assigned the UTC method
/* because the date method only returns the days of the week in numbers 0-6
I am obliged to use the arrrays to proceed the computation */
// writing the array statement
let weekArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
if (currentDay >= 0 && currentDay < weekArray.length){ // I introduced the if statement to help me check the truth value and return the Date
console.log(weekArray[currentDay])
return weekArray[currentDay];
}
else {
console.log("Invalid Time");
}
}
dayOfWeek();
setInterval(function () {
// now to using DOM to manipulate and reflect on HTML page
document.querySelector('[data-testid="currentDayOfTheWeek"]').innerHTML = dayOfWeek();
}, 1000);
//to get the time
function time(){
let dispTime = new Date();
let standardMilliSeconds = dispTime.getUTCMilliseconds();
let newTime = (standardMilliSeconds + "ms");
console.log(newTime);
return newTime;
}
time();
setInterval(time, 1000);
setInterval(function () {
document.querySelector('[data-testid="currentUTCTime"]').innerHTML = time();
}, 1000);
//clickable link to the github repo
document.querySelector('[data-testId="githubURL"]').innerHTML = '<a href="https://github.com/livinalt/stageOne">Visit Repo</a>';