Skip to content

Commit be42de4

Browse files
feat: add ternary operator
1 parent ecf30c8 commit be42de4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

part1 (Basics)/17_ternary.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Ternary Operator in JavaScript
2+
3+
/*
4+
? : Ternary conditional operator
5+
Syntax: condition ? expressionIfTrue : expressionIfFalse
6+
Returns one of two expressions based on a condition.
7+
*/
8+
9+
const age = 18;
10+
const canVote = age >= 18 ? 'Yes' : 'No';
11+
console.log(canVote); // Output: Yes

0 commit comments

Comments
 (0)