JavaScript
🔀 Conditionals
Give your program the power to decide with if/else, the ternary operator and switch: the first step toward something that feels smart.
What you'll learn
- Branch execution with
if,else ifandelse, ordering the conditions from most to least demanding. - Identify the falsy values (
false,0,"",null,undefined,NaN) and predict the result of a truthy condition. - Write a conditional assignment with the ternary operator
condition ? a : b. - Compare a variable against fixed values with
switchusingbreakanddefault.
Lessons
if, else if and elseGive your program the power to decide: run code only when a condition is met. Truthy/falsy and the ternary operatorWhich values count as true and how to resolve an if in a single line. The switch structureCompare a variable against many fixed values.Practice this module in the app
DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.
Start free in the app →