Conditional Logic and Control Flow Slides
Conditional Logic and Control Flow Slides
Control Flow
David Tucker
CTO Consultant
@_davidtucker_ | davidtucker.net
index.js
// Example 1
let example1 = (10 > 4);
Comparison console.log(example1); // Output: true
Operators
// Example 2
let example2 = (5 >= 5);
console.log(example2); // Output: true
index.js
// Example 3
let example3 = ("Hello" === "Hi");
Equality console.log(example3); // Output: false
Operators
// Example 4
let example4 = (4 !== 7);
console.log(example4); // Output: true
index.js
// Using Conditionals
let badgeColor;
if (numYearsService < 5) badgeColor = "blue";
if (numYearsService < 5) {
badgeColor = "blue";
Using } else if (numYearsService < 10) {
badgeColor = "yellow";
Conditionals } else if (numYearsService < 15) {
badgeColor = "red";
} else if (numYearsService < 20) {
badgeColor = "purple";
} else {
badgeColor = "silver";
}
Mathematical Operators
Assignment Operators
Increment and Decrement Operators
If used prefix, with operator before operand (for example,
++x), the increment operator increments and returns the
value after incrementing.
If used postfix, with operator after operand (for example,
x++), the increment operator increments and returns the
value before incrementing.