Skip to content

Commit a14ace2

Browse files
committed
config control flow
1 parent bdbb83b commit a14ace2

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

js_basics/control_flow.js

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// if
2+
// const isUserloggedIn = true
3+
// const temperature = 41
4+
5+
// if ( temperature === 40 ){
6+
// console.log("less than 50");
7+
// } else {
8+
// console.log("temperature is greater than 50");
9+
// }
10+
11+
// console.log("Execute");
12+
// <, >, <=, >=, ==, !=, ===, !==
13+
14+
// const score = 200
15+
16+
// if (score > 100) {
17+
// let power = "fly"
18+
// console.log(`User power: ${power}`);
19+
// }
20+
21+
// console.log(`User power: ${power}`);
22+
23+
24+
// const balance = 1000
25+
26+
// if (balance > 500) console.log("test"),console.log("test2");
27+
28+
// if (balance < 500) {
29+
// console.log("less than 500");
30+
// } else if (balance < 750) {
31+
// console.log("less than 750");
32+
33+
// } else if (balance < 900) {
34+
// console.log("less than 750");
35+
36+
// } else {
37+
// console.log("less than 1200");
38+
39+
// }
40+
41+
// const userLoggedIn = true
42+
// const debitCard = true
43+
// const loggedInFromGoogle = false
44+
// const loggedInFromEmail = true
45+
46+
// if (userLoggedIn && debitCard && 2==3) {
47+
// console.log("Allow to buy course");
48+
// }
49+
50+
// if (loggedInFromGoogle || loggedInFromEmail) {
51+
// console.log("User logged in");
52+
// }
53+
54+
55+
56+
// switch (key) {
57+
// case value:
58+
59+
// break;
60+
61+
// default:
62+
// break;
63+
// }
64+
65+
// const month = "march"
66+
67+
// switch (month) {
68+
// case "jan":
69+
// console.log("January");
70+
// break;
71+
// case "feb":
72+
// console.log("feb");
73+
// break;
74+
// case "march":
75+
// console.log("march");
76+
// break;
77+
// case "april":
78+
// console.log("april");
79+
// break;
80+
81+
// default:
82+
// console.log("default case match");
83+
// break;
84+
// }
85+
86+
const userEmail = []
87+
88+
if (userEmail) {
89+
console.log("Got user email");
90+
} else {
91+
console.log("Don't have user email");
92+
}
93+
94+
// falsy values
95+
96+
// false, 0, -0, BigInt 0n, "", null, undefined, NaN
97+
98+
//truthy values
99+
// "0", 'false', " ", [], {}, function(){}
100+
101+
// if (userEmail.length === 0) {
102+
// console.log("Array is empty");
103+
// }
104+
105+
// const emptyObj = {}
106+
107+
// if (Object.keys(emptyObj).length === 0) {
108+
// console.log("Object is empty");
109+
// }
110+
111+
// Nullish Coalescing Operator (??): null undefined
112+
113+
let val1;
114+
// val1 = 5 ?? 10
115+
// val1 = null ?? 10
116+
// val1 = undefined ?? 15
117+
val1 = null ?? 10 ?? 20
118+
119+
120+
121+
console.log(val1);
122+
123+
// Terniary Operator
124+
125+
// condition ? true : false
126+
127+
const iceTeaPrice = 100
128+
iceTeaPrice <= 80 ? console.log("less than 80") : console.log("more than 80")

0 commit comments

Comments
 (0)