-
Notifications
You must be signed in to change notification settings - Fork 0
/
if-statements
47 lines (37 loc) · 921 Bytes
/
if-statements
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
let animal = "cat" //global scope
animal = "dog"
animal = "snake"
if (animal === "dog" || animal === "Dog" || animal === "snake") {
animal = "snake" // block scoped
console.log("woof", animal)
} else {
console.log("your animal is ", animal)
}
let person = "mammal"
person = "not mammal"
console.log(person)
if (person === "Mammal") {
console.log("yes though so!")
} else if (person && 0) {
console.log("not sure")
} else if (person === "not mammal") {
console.log("this is catch all")
} else {
console.log("catch all")
}
/* Date */
const date = new Date()
console.log(date)
const hours = date.getHours()
console.log(hours)
if (hours > 12) {
console.log("is past lunch time")
} else if (hours <= 11.5) {
console.log("is almost lunch time")
}
const today = date.getDate()
console.log(today)
if (today === 12) {
console.log("Happy July 12th")
}
if (today === 12) console.log("Happy July 12th")