Please enable JavaScript to use CodeHS

Introduction to Computer Science in JavaScript (Golden) (2022)

Lesson 5.10 Loop and a Half

Description

In this lesson, students will learn how to create a Loop and Half. A Loop and a Half is a specific way to write a while loop with the condition being true. Inside the loop, students create a SENTINEL value to break out of the loop whenever that condition is met, causing the loop to end.


Objective

Students will be able to:

  • Explain how the loop-and-a-half structure is different from a traditional while loop
  • Explain what an infinite loop is
  • Explain what the break statement does
  • Create programs that use the loop-and-a-half structure to repeat code until a SENTINEL is met, causing the program to break out of the loop