Loops
Lesson 1 of 1
  1. 1
    A loop is a way of repeating a block of code until a certain condition is met. Loops build on top of the logic found in conditional if statements. When an if statement’s condition is true, its…
  2. 2
    An if statement allows us to check a specific condition once. But what if that condition needs to be checked a certain number of times? Definite loops can be used to repeat code a fixed number…
  3. 3
    Sometimes it is impossible to know how many iterations of a loop are needed ahead of time. For example, imagine if a club is throwing an event to promote new member sign-ups. The club has to proce…
  4. 4
    Sometimes an indefinite loop does not end, creating an infinite loop. An infinite loop is a loop where the condition can never be reached, causing the loop to run forever. Sometimes this can …
  5. 5
    How does a programmer get more direct control over a loop? With the break and continue keywords! The break keyword allows the programmer to stop the loop at the current iteration. For example, if…
  6. 6
    Maps and arrays are some of the most fundamental data structures. Reading and modifying their contents will be done often in any codebase. Luckily, their properties grant them an easy-to-use synta…
  7. 7
    Congratulations! You have made it through the lesson! Loops are a staple in any programmer’s toolbox for automating repetitive tasks. Similar to an if statement, a loop repeats a block of cod…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo