Skip to content

Class 02 (Conditionals & Debugging)

KJ Monahan edited this page May 14, 2024 · 2 revisions

Lesson 2: Conditionals and Debugging

In the prep work for this lesson, the students learned:

  1. The boolean data type and boolean expressions
  2. Logical operators (>, <, etc.) and == vs. ===
  3. Logical AND, OR, and NOT
  4. if / else if / else statements
  5. Three common error types (syntax, runtime, logic)
  6. How to use console.log to help debug code

Large Group Time (Instructor Notes)

Announcements

For Part-Time Students

  1. Note the due date for the first graded assignment (should be 2 - 4 weeks away).
    1. Assignment 1 has been broken into 3 parts. Check Canvas for the due dates for each part.
  2. The assignment will be active in Canvas soon, and the students will know enough after lesson 2 to begin the first part of the assignment.

For Full-Time Students

  • Welcome to Day 2

Lesson 2 Topics That Require More Attention

  1. Q & A from the prep work and/or exercises.
    1. Recommend walking through the debugging exercises to reinforce how to spot the different error types, how to use error messages to find bugs, and how to systematically find and fix logic errors.
  2. Emphasize why === should be used instead of ==.
  3. Review the meaning of the truth tables for logical AND and logical OR.
  4. Clarify with live coding examples:
    1. The difference between an if / else if block and two successive if blocks
    2. Nested conditionals
    3. Check multiple conditions with && and ||
    4. When would we use !?

Studio (IA Notes)

  1. Provide an overview of how studio sessions run and how to best take advantage of the time.
    1. Tasks will be completed in GitHub. Learners will submit a single GitHub URL for everyone in their group.
    2. Studios provide focused practice in a supervised, safe space. Students are free to explore, make mistakes, and ask for tips.
    3. Studios are NOT graded, but active participation is essential for success in the class.
    4. Learners may not be able to finish the entire studio in time. It's more important that they try things out and learn than it is that they check off every requirement -- only the graded assignments are reviewed and graded
    5. Provide a quick introduction to the Data & Variables studio if the lead instructor did not already do so
    6. Wrap-up about 10 minutes before the end and share the attendance code and go over again what they need to submit. (The single URL for the group is confusing at first, since elsewhere we stress that everything needs to be their own work.)
  2. Demonstrate pair programming first
  3. Help students successfully navigate to the right directory in their repository.
  4. Encourage best practices for variable names.
  5. Studios are NOT graded, but for this first task, you should do a visual check of each student's output. The best time to do this is during the studio!
  6. Common mistake:
    1. Some students will miss the idea of using variables to create the output. Instead, they will hard code the data values into the console.log statements.
    2. Encourage the students to use variables, and explain that doing so allows the output to reflect any changes in the data.
    3. When the students run their code for you, ask them to change astronautCount to a different number (like 3), and then verify that the output reflects the new value.
  7. Recognize any clever ideas that the students use to print the tedious parts of the output.
  8. Even though you do a visual check of the code, students should still "Submit" the GitHub URL in Canvas. That way, they preserve a record of their participation.