We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e5c4764 commit cc05670Copy full SHA for cc05670
part1 (Basics)/operators/06_ternary.js
@@ -9,3 +9,23 @@ Returns one of two expressions based on a condition.
9
const age = 18;
10
const canVote = age >= 18 ? 'Yes' : 'No';
11
console.log(canVote); // Output: Yes
12
+
13
14
+/*
15
+? : Nested Ternary conditional operator
16
+Nested ternary means using a ternary inside another ternary.
17
+Useful when you have multiple conditions to check.
18
+*/
19
20
+const userAge = 20;
21
22
+const status = userAge < 13
23
+ ? "Child"
24
+ : userAge < 18
25
+ ? "Teenager"
26
+ : userAge < 60
27
+ ? "Adult"
28
+ : "Senior";
29
30
+console.log(status); // Output: Adult
31
0 commit comments