-
Notifications
You must be signed in to change notification settings - Fork 59
Class 04 (Loops)
KJ Monahan edited this page May 14, 2024
·
1 revision
In the prep work for this lesson, the students learned:
- How to write
for
andwhile
loops:- Proper syntax
- Iterating over strings and arrays
- Adding a
break
statement within a loop
- When one type of loop is preferred over the other for the following cases:
- Known vs. unknown number of iterations
- Input validation
- The accumulator pattern.
- Reminder of the due date for the first graded assignment.
- After this class, the students will have all the skills necessary to complete the assignment.
- Welcome to Day 4!
- As needed
- Live coding, live coding, live coding!
- Present a sequence of challenges for students, then ask for them to contribute to the solutions presented to the class. Start simple, then increase the complexity of the tasks.
- Review how to use increments other than
i++
in a loop. - Show how to use a
while
loop to validate user input.
- Tips for avoiding infinite loops and what to do when you create one anyway.
- Discuss when one type of loop is preferred over the other.
- Emphasize that even though a
while
loop can be used in place of afor
loop, afor
loop should NOT be used to replace awhile
loop. - Studio intro:
- Provide a general rundown of what needs to be accomplished with the meal assembly - one meal array for each crew member, and each meal array consists of one item from each of the ingredient arrays.
- Encourage the students to try the bonus missions if they finish the main studio content early.
- This studio contains unit tests, like the Lesson 3 studio.
- Students will need to work with multiple functions for this studio. Notes have been provided in the textbook and the starter code.
- Common learner stumbling blocks:
- The provided starter code contains the entire studio, along with unit tests.
- For the self-destruct mission, the examples were carefully chosen to use strings with the same length. If a student wants to use strings of different lengths (which throws an error), help them add some validation to their code to deal with this.
- Using a multi-dimensional array helps streamline the process of meal assembly, but students tend to avoid using one. After their code works, encourage them to explore how a 2-D array helps reduce the lines of code.
- As always, be sure to check-in with each of your students.