Please enable JavaScript to use CodeHS

Chapter 2

JavaScript Control Structures

2.1 Booleans Booleans Overview First Boolean Check Your Understanding Exercise: Do You Have a Cat?
2.2 Logical Operators What Are Logical Operators? The NOT Operator Light Switch The AND Operator The OR Operator Wasting Time Check Your Understanding Exercise: Can You Drive?
2.3 Comparison Operators Basic Comparisons Grade Range Voting Age Check Your Understanding Exercise: Rolling Dice
2.4 If Statements Negative Numbers If/Else Statements Even and Odd Secret Password Check Your Understanding Exercise: Ride Height
2.5 For Loops in JavaScript For Loop Example Variations on the Basic For Loop Countdown Count By Twos For Loop Sum Check Your Understanding Exercise: Chalkboard
2.6 Random Numbers Randomizer Rolling a Die More Things To Do With The Randomizer Flipping a Coin Check Your Understanding Exercise: Lots of Rolls
2.7 While Loops While Loop In Action While Loop Countdown While Loops with User Input Beware of Infinite Loops Check Your Understanding Exercise: Inventory
2.8 Loop and a Half The Infinite Loop The Break Statement The Sentinel Adding Up Numbers Check Your Understanding Exercise: Double Sixes
2.9 Functions and Parameters Parameters Defining a Function with Parameters Calling a Function with Arguments Double Number Multiple Parameters Sum Function Parameters and Reusable Code Draw Circles Check Your Understanding Exercise: Rectangle
2.10 Functions and Return Values Keeping Results Calling a Function With a Return Value Double Number Multiple Parameters With a Return Value Return Values Check Your Understanding Exercise: Rectangle with Return Values
2.11 Local Variables and Scope What Are Local Variables? What is Scope? Why Scope Matters Return Values and Scope Other Scope Examples Check Your Understanding Exercise: Local Variables