4 CONDITIONALS AND LOOPS

Conditionals and loops are essential elements in programming. They add logic and structure to your programs by allowing your code to make decisions based on specific conditions. Together, conditionals and loops are known as control structures because they give you control over when and how often parts of your code should run. With conditionals, you can run a particular piece of code only if a certain condition is true. Meanwhile, loops enable you to repeatedly run a piece of code for as long as a condition remains true.

In this chapter you’ll learn how to conditionally execute code with if statements and how to loop ...

Get JavaScript Crash Course now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.