Skip to content

Commit 1c3d56d

Browse files
committed
Minor changes, add another example for ternary operators
1 parent d7f93b5 commit 1c3d56d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Tutorials/Basic/01_variables/04C_condtional_operations.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@
99
* Syntax:
1010
* variable = (condition) ? TRUE_value: FALSE_value
1111
*/
12+
1213
let age = 18;
1314
let canVote = (age >= 18) ? "Yes" : "No"; // ternary operator
1415
console.log(canVote)
1516

17+
// Another Example
18+
19+
let speed = 90;
20+
// let speed = 50;
21+
let overSpeeding = (speed >=80 ) ? true: false
22+
console.log(overSpeeding)
23+
1624
// Multiple (Nested) Conditional (Ternary) operators
1725

1826
function checkInt (num) {
1927
return (num > 0) ? "Positive" : (num < 0) ? "Negative" : "Zero";
2028
}
2129

22-
console.log(checkInt(0))
30+
console.log(checkInt(0))

0 commit comments

Comments
 (0)