Learn Go: Loops
This lesson will introduce you to loops.
StartLoops
Lesson 1 of 1
- 1A 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…
- 2An 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…
- 3Sometimes 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…
- 4Sometimes 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 …
- 5How 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…
- 6Maps 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…
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory