-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolflowex1.js
138 lines (85 loc) · 2.13 KB
/
controlflowex1.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
109
110
111
112
113
114
115
116
//console.log('Control flow starts');
//if statement
// if(condition){
// }
// const isuserloggedin=true
// if(isuserloggedin){
// console.log('Welcome to Home Page');
// }
// if(2==='2'){
// console.log('run');
// }
// if(2>11){
// console.log("yes u r right");
// }else{
// console.log('no u r wrong');
// }
// if(4>2){
// const user="Akki"
// console.log('u are again right');
// }
//implicit scope
//const balance=500
//if(balance>300) console.log("ameer log");
// const bal=1000
// if(bal<500){
// console.log('balance less than 500');
// }else if(bal<750){
// console.log('less than 750');
// }else{
// console.log('greater than all');
// }
// const userLoggedin=true
// const debitCard=true
// const loginfromgoogle=true
// const loginnfromemail=false
// if(userLoggedin && debitCard){
// console.log('allow to buy course');
// }
// if(loginfromgoogle && loginnfromemail){
// console.log('allow to log in');
// }
//switch statement
// switch (key) {
// case value:
// break;
// default:
// break;
// }
// const month=1
// switch (month){
// case 1: console.log('January');
// break
// case 2: console.log('Februray');
// break;
// case 3: console.log('March');
// break;
// case 4: console.log('April');
// break;
// default:console.log('Default matched');
// break;
// }
//false values: false, empty string,0,-0,BinInt 0n,null,undefined,NaN
//truthy values :rest all true as empty array [],"0","false"," ",{},function(){}
// const userEmail=[1,2,3]
// if(userEmail){
// console.log("welcome to home");
// }else{
// console.log("niklo yha se");
// }
//Nullish Coalescing Operator(??): entire story revolves around "null" and "undefined"
let val1;
val1=5 ?? 10
console.log(val1);
val1=null ?? 10
console.log(val1);
var1=undefined ??15
console.log(var1);
var2= null?? 10 ?? 20
console.log(var2);
//ternary operator
// condition?true:false
let a=10
let b=20
let res=a>b?a:b
console.log(`greater between ${a} and ${b} is : ${res}`);