JavaScript Lesson 2: Control Flow, Functions, and Loops
Page 1: Conditional Statements
What are Conditional Statements?
o Conditional statements allow you to execute code based on specific conditions.
o The most common are if, else if, and else statements.
Using if statements:
o Syntax:
Page 2: Comparison and Logical Operators
Comparison Operators: These operators compare values and return true or false.
o ==: Equal to
o !=: Not equal to
o ===: Strict equal (checks type as well)
o !==: Strict not equal
o <, >, <=, >=: Less than, greater than, etc.
Example:
Logical Operators: Used to combine multiple conditions.
&&: Logical AND (both conditions must be true)
||: Logical OR (either condition can be true)
!: Logical NOT (inverts the condition)
Page 3: Functions in JavaScript
What is a Function?
o A function is a block of reusable code that performs a specific task.
o Functions help to keep your code organized and reduce repetition.
Creating a Function: Syntax: