# Decisions and Loops

Make your programs choose and repeat: if and else for decisions, && and || to combine conditions, switch and the conditional operator for many choices, and while and for loops for work that repeats.

Updated: November 14, 2026

## [Conditions in JavaScript](https://www.ask-codey.com/courses/javascript-in-depth/topics/javascript-conditions)

1. [Making Decisions with if and else](https://www.ask-codey.com/lessons/javascript-conditions-if-and-else) (Novice): An if statement runs a block of code only when its condition is true, else gives the other path, and else if chooses between several, so your program can react to what's going on.
2. [Combining Conditions with And, Or and Not](https://www.ask-codey.com/lessons/javascript-conditions-and-or-not) (Apprentice): The logical operators && (and), || (or) and ! (not) join small true-or-false checks into one condition, so a single if can follow a real rule with several parts.
3. [switch and the Conditional Operator](https://www.ask-codey.com/lessons/javascript-conditions-switch-and-ternary) (Apprentice): A switch statement matches one value against a list of exact choices, and the conditional operator ? : picks one of two values in a single line, so a long chain of else ifs can say what it means.

## [Loops in JavaScript](https://www.ask-codey.com/courses/javascript-in-depth/topics/javascript-loops)

1. [Repeating with while](https://www.ask-codey.com/lessons/javascript-loops-while) (Novice): A while loop repeats a block of code for as long as its condition stays true, which fits any job where you can't know in advance how many times it will take, as long as something inside the loop lets it end.
2. [Counting with for](https://www.ask-codey.com/lessons/javascript-loops-for) (Novice): A for loop puts its start, its condition and its step in one line, so counting up, counting down or counting by any step reads at a glance, and break and continue let you stop early or skip a pass.

## [Exercise: Bike Rental Prices](https://www.ask-codey.com/courses/javascript-in-depth/topics/exercise-javascript-bike-rental-prices)

1. [Exercise: Bike Rental Prices](https://www.ask-codey.com/lessons/exercise-javascript-bike-rental-prices) (Apprentice): Finish four functions for a bike rental shop, using conditions, the conditional operator and a for loop, and let the tests check every price, bike size and group receipt.

Source: https://www.ask-codey.com/courses/javascript-in-depth/chapters/decisions-and-loops-in-javascript
