-
Notifications
You must be signed in to change notification settings - Fork 0
/
flow-control.js
executable file
·60 lines (54 loc) · 1.03 KB
/
flow-control.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
function basicTeenager(age) {
if (age >= 13 && age <= 19){
return "You are a teenager!"
}
}
function teenager(age) {
if (age >= 13 && age <= 19){
return "You are a teenager!"
} else {
return "You are not a teenager"
}
}
function ageChecker(age) {
if (age >= 13 && age <= 19){
return "You are a teenager!"
} else if (age <= 12){
return "You are a kid"
} else {
return "You are a grownup"
}
}
function ternaryTeenager(age) {
return age >= 13 && age <= 19 ?
'You are a teenager':
'You are not a teenager'
}
var age = 13
function switchAge(age) {
switch(age) {
case age = 13:
return "You are a teenager";
break;
case age = 14:
return "You are a teenager";
break;
case age = 15:
return "You are a teenager";
break;
case age = 16:
return "You are a teenager";
break;
case age = 17:
return "You are a teenager";
break;
case age = 18:
return "You are a teenager";
break;
case age = 19:
return "You are a teenager";
break;
default:
return "You have an age"
}
}