-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl-Statements-in-JS.js
More file actions
141 lines (115 loc) · 3.13 KB
/
Control-Statements-in-JS.js
File metadata and controls
141 lines (115 loc) · 3.13 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* control statements :-
---> (if)
---> (if)-(else)
---> (if)-(else-if)
---> (if)-(else-if)-(else)
---> (switch)-(case)
*/
// (if)
const temp=30
if(temp>15 && temp<35){
console.log("temp value is between 15 and 35 which is :- ",temp)
}
const age=20
if(age>=18){
console.log("candidate can vote because their age is :- ",age)
}
//------------------------------------------------------------------------------------------------------
// (if)-(else)
const day1="monday"
const day2="sunday"
if(day1=="monday" || day2=="tuesday"){
console.log("either day1 is monday or day2 is tuesday")
}
else{
console.log("neither day1 is monday nor day2 is tuesday")
}
const colour="blue"
const num="2112"
if(colour==="blue"){
console.log("colour is blue")
}
if(num===2112){
console.log("code is Number(2112)")
}
else{
console.log("code is not Number(2112) it's ",num," ,with data type :-",typeof(num))
}
//------------------------------------------------------------------------------------------------------
//(if)-(else-if)
const person_age=37
if(person_age<18){
console.log("person age is less than 18")
}
else if(person_age==18){
console.log("person age is equal to 18")
}
else if(person_age>18 && person_age<=30){
console.log("person age is greater than 18 and less than or equal to 30")
}
else if(person_age>30 && person_age<=50){
console.log("person age is greater than 30 and less than or equal to 50")
}
else if(person_age>50){
console.log("person age is above 50")
}
//------------------------------------------------------------------------------------------------------
//(if)-(else-if)-(else)
const balance_in_account=750
const accouont_type="shared"
if(balance_in_account == 0){
console.log("account balance is 0")
}
else if(balance_in_account<=500 && accouont_type=="FD"){
console.log("account balance is greater than equal to 500 and account is FD type")
}
else if(balance_in_account<=500 || accouont_type=="FD"){
console.log("account balance is greater than equal to 500 or account is FD")
}
else if(balance_in_account<=1000 && accouont_type=="shared"){
console.log("account balance is greater than equal to 1000 and account is shared type")
}
else{
console.log("account balance is greater than 1000")
}
//------------------------------------------------------------------------------------------------------
//(switch)-(case)
const month=3
switch(month){
case 1:
console.log("monthe is jan!!")
break
case 2:
console.log("monthe is feb!!")
break
case 3:
console.log("monthe is march!!")
break
case 4:
console.log("monthe is april!!")
break
case 5:
console.log("monthe is may!!")
break
default:
console.log("month is above 5 ! !")
break
}
const exp=2*2+1
switch(exp){
case 1:
console.log("exp val is 1")
break
case 2:
console.log("exp val is 2")
break
case 3:
console.log("exp val is 3")
break
case 4:
console.log("exp val is 4")
break
default:
console.log("exp value is greater than 4!!")
break
}