-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionals.js
55 lines (46 loc) · 1.09 KB
/
conditionals.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
// exercise 1
/*
const raining = true;
const cold = false;
if (raining) {
console.log("Don't forget your umbrella!"); // will only run if true
}
if (cold) {
console.log("Make sure you pick out a scarf!"); // will only run if true
}
console.log("Now you're ready to be outside!"); // will always run
*/
// exercise 2
/*
const cold = false; // if you want to do one thing or another; IE 2 options
if (cold) {
console.log("Make sure you pick out your scarf!");
} else {
console.log("Short sleeves are fine.");
}
*/
// exercise 3
/*
const temperature = 16;
if (temperature < 0) {
console.log("Make sure you pick out a scarf!");
} else if (temperature < 15) {
console.log("Short sleeves won't cut it!");
} else {
console.log("Short sleeves are fine.");
}
console.log("Now you're ready to go outside!"); // will always run
*/
// logical operators :
// && - logical AND
// || - logical OR
// "!"- logical NOT
// exercise 4
/*
const isCitizen = true;
const age = 26;
if (isCitizen && age > 18) { // && makes it so both comparisons must be true
console.log("You are eligible to vote.")
}
*/
//exercise 5