-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrolFlow.js
More file actions
80 lines (76 loc) · 1.69 KB
/
controlFlow.js
File metadata and controls
80 lines (76 loc) · 1.69 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
Conditional statements are used to run pieces of code to demonstrate if a certain condition is true or false
*/
var result = 20;
if (result > 40) {
console.log("Congratulations you passed the text!");
} else {
console.log("Unfortunately you did not pass the test");
}
//Else if
var position = "first";
if (position === "first") {
console.log("Gold");
} else if (position === "second") {
console.log("silver");
} else if (position === "third") {
console.log("bronze");
} else {
console.log("No medals");
}
/*switch statements are used when there are blocks of conditions to be checked
if else and switch statements are sometimes referred to as flow control statements.
var key = "value"
switch (key) {
case value:
console.log("some result")
break;
case value:
console.log("some result")
break;
default:
console.log("default result")
break;
}
*/
var place = "first";
switch (place) {
case "first":
console.log("Gold");
break;
case "second":
console.log("Silver");
break;
case "third":
console.log("Bronze");
break;
default:
console.log("No medal");
break;
}
var day = "Wednesday";
switch (day) {
case "Monday":
console.log("Women's fellowship");
break;
case "Tuesday":
console.log("Men's fellowship");
break;
case "Wednesday":
console.log("Watch and Pray");
break;
case "Thursday":
console.log("6am-6pm fasting");
break;
case "Friday":
console.log("Spirited fellowship");
break;
case "Saturday":
console.log("Sabbath Fasting");
break;
case "Sunday":
console.log("Sunday Service");
break;
default:
console.log("There is no such day");
}