Skip to content

Commit c3186fc

Browse files
committed
ternary operator
1 parent 696e2c6 commit c3186fc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

29_ternary_operator.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ternary operator
2+
// condition ? (runs if true) : (runs if false)
3+
4+
const values = 10 > 5;
5+
6+
//values ? is condition
7+
values
8+
? console.log('10 bigger than five')
9+
: console.log('print if this false');
10+
11+
// // example use if else
12+
// const values = 10 > 5;
13+
// if (values) {
14+
// console.log('10 bigger than five');
15+
// } else {
16+
// console.log('false statement');
17+
// }
18+
// // output: 10 bigger than five

0 commit comments

Comments
 (0)