-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
61 lines (43 loc) · 2 KB
/
app.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Clock */
const timeClockOptions = {
hour: "numeric",
minute: "numeric"
}
const timeOfDay = () => {
const currentDay = new Date()
let clockTime = currentDay.toLocaleTimeString("en-GB", timeClockOptions)
const timeClock = clockTime
document.querySelector("#timeOfDay").innerHTML = timeClock
}
const updateTime = setInterval(timeOfDay, 1000)
timeOfDay(updateTime)
/* Greet User */
const welcomeGreet = () => {
const currentDate = new Date()
const amountOfHours = currentDate.getHours()
const user = "Erik"
let welcomeMessage = ""
if (amountOfHours < 12) {
welcomeMessage = 'Good morning'
} else if (amountOfHours >= 12 && amountOfHours <= 17) {
welcomeMessage = 'Good afternoon'
} else if (amountOfHours >= 17 && amountOfHours <= 24) {
welcomeMessage = 'Good evening'
}
document.querySelector("#GreetUser").innerHTML = `${welcomeMessage}, ${user}.`
}
welcomeGreet(updateTime)
/* Pick Random Message from Array */
const upliftingMessage = () => {
const upliftingMessageArray = ['What is your main focus for today?', 'What are your plans for today?', 'Get started on a new project today', 'Remember to stay positive.'];
const randomChoice = upliftingMessageArray[Math.floor(Math.random() * upliftingMessageArray.length)];
document.querySelector("#GoalofToday").innerHTML = `${randomChoice}`
}
upliftingMessage()
/* Pick Random Quote from Array */
const randomQuote = () => {
const randomQuoteFromArray = ['"As long as there are sovereign nations possessing great power, war is inevitable." - Albert Einstein', '"The best argument against democracy is a five-minute conversation with the average voter." - Winston Churchill', '"A good plan violently executed now is better than a perfect plan executed next week." - George S. Patton'];
const randomChoice = randomQuoteFromArray[Math.floor(Math.random() * randomQuoteFromArray.length)];
document.querySelector("#randomQuote").innerHTML = `${randomChoice}`
}
randomQuote()