0 of 10 problems solved • 0%
Use in a course

Conditions and Branching

10 exercisesEasy

Conditions let the same program choose different actions for different inputs. An if branch runs only when its condition is true, while else if and else cover the remaining cases.

const temperature = 12; if (temperature < 5) { console.log("Wear a winter coat"); } else if (temperature < 15) { console.log("Bring a jacket"); } else { console.log("Enjoy the sunshine"); }

The exercises build from simple checks to carefully ordered branches and combined conditions, without hiding the rule the code is meant to express.