-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditional.js
108 lines (86 loc) · 1.33 KB
/
conditional.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
// if statement
let age=18;
if(age==18){
console.log('vote')
}
*/
/*
// if_else statement
let varible='var';
if(varible != undefined){
console.log('exists')
}
else{
console.log('Doesn\'t exist')
}
*/
/*
let user = true;
if(user){
console.log('access')
}
else{
console.log('get lost')
}
*/
/*
// else if statement
let num=0;
if(num<0){
console.log('negative')
}
else if(num>0){
console.log('positive')
}
else{
console.log('zero')
}
*/
/*
let user=true;
let varible='var';
if(user && varible != undefined){
let myhtml = `the ${ varible} exists and the ${user} is true`
// console.log('it works')
document.body.innerHTML = myhtml
}
else{
console.log('try again')
}
*/
/*
let age=18;
console.log((age==45)? 'true':'false');
*/
/*
array=['anme', 'game', 'bame', 'fame']
if(array.includes('fame')){
console.log(true)
}
else{
console.log(false)
}
*/
// Switch
let age = 40;
switch (age) {
case 18:
console.log(`you are ${age} years old`);
break;
case 20:
console.log(`you are ${age} years old`);
break;
case 30:
console.log(`you are ${age} years old`);
break;
case 40:
console.log(`you are ${age} years old`);
break;
case 50:
console.log(`you are ${age} years old`);
break;
default:
console.log("user age unknown");
break;
}