File tree Expand file tree Collapse file tree 1 file changed +32
-9
lines changed Expand file tree Collapse file tree 1 file changed +32
-9
lines changed Original file line number Diff line number Diff line change 1
1
function basicTeenager ( age ) {
2
-
2
+ if ( age >= 13 && age <= 19 ) {
3
+ return "You are a teenager!" ;
4
+ }
3
5
}
4
6
5
- function teenager ( age ) {
6
-
7
+ function teenager ( age ) {
8
+ if ( age >= 13 && age <= 19 ) {
9
+ return "You are a teenager!" ;
10
+ } else {
11
+ return "You are not a teenager" ;
12
+ }
7
13
}
8
14
9
- function ageChecker ( age ) {
10
-
15
+ function ageChecker ( age ) {
16
+ if ( age >= 13 && age <= 19 ) {
17
+ return "You are a teenager!" ;
18
+ } else if ( age < 13 ) {
19
+ return "You are a kid" ;
20
+ } else {
21
+ return "You are a grownup" ;
22
+ }
11
23
}
12
24
13
- function ternaryTeenager ( age ) {
14
-
25
+ function ternaryTeenager ( age ) {
26
+ return age >= 13 && age <= 19 ? "You are a teenager" : "You are not a teenager"
15
27
}
16
28
17
- function switchAge ( age ) {
18
-
29
+ function switchAge ( age ) {
30
+ switch ( age ) {
31
+ case 13 :
32
+ case 14 :
33
+ case 15 :
34
+ case 16 :
35
+ case 17 :
36
+ case 18 :
37
+ case 19 :
38
+ return "You are a teenager" ;
39
+ default :
40
+ return "You have an age"
41
+ }
19
42
}
You can’t perform that action at this time.
0 commit comments