-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestedTernary.js
74 lines (60 loc) · 1.4 KB
/
NestedTernary.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
/*if(authentiacted){
renderApp();
} else {
renderLogin(); // or redirect to login page
}
*/
// Using async/await for better readability
//authenticated ? renderApp() : renderLogin();
// condition ? ValueIfTrue : ValueIfFalse
//condition ? ValueIfFalse : ValueIfFalse
// condition ? ValueIfTrue : ValueIfFalse
// condition ? ValueIfTrue : ValueIfFalse
// condition ? ValueIfTrue : ValueIfFalse
/*const age =20;
const canVote = age >18 ? "yes" : "no";
console.log(canVote);
const age = 20;
const CanVote=age <=20 ? "yes " : "no";
console.log(CanVote);
const num = 15 ;
const type = num >0 ? ( num %2 == 0 ? "positive even number " : " positive odd number "): " negative"
console.log(type);
const num = 799;
const range = num < 0
? 'negative'
: num >= 0 && num <50
? " Between 0 and 50 "
:num >=50 && num <100
? " Between 50 and 100 "
: " above 100"
console.log(range); *
const num = 55;
const range = num <0
? 'negative '
: num >= 0 && num <50
? " Between 0 and 50 "
: num >=50 && num <100
? " Between 50 and 100 "
: " above 100"
console.log(range);
const role = "admin";
const accessLevel = role == "admin"
? "Full Access "
: role =="Editor"
?"Edit Access"
:role == "viewers"
? "Only view"
:"No access"
console.log(accessLevel); */
const score = 95;
const grade = score >= 90
? "A grade"
: score >= 70
? "B grade"
: score >= 60
? "C grade"
: score >= 50
? "D grade"
: "F grade"
console.log(grade);