Programs make decisions with if, else if, and else blocks. The condition in an if statement is evaluated for truthiness, and JavaScript will coerce any non-boolean value into a boolean in that context. When many branches depend on the same expression, a switch statement provides a cleaner alternative: it evaluates the expression once and dispatches to the matching case, with break statements used to stop execution from falling through, and an optional default branch for any unmatched value.
Loops repeat actions. A for loop uses the form for (init; condition; increment) { ... }, where the initializer runs once, the condition is checked at the start of every iteration, and the increment runs at the end. The while loop also checks its condition before each iteration, but the do-while loop flips that order: it executes the body first and then checks the condition, guaranteeing at least one iteration. These looping constructs let you traverse arrays, repeat calculations, or process user input until a stop condition is reached.
Functions are reusable blocks of behavior. They can be declared with function name(parameters) { ... }, in which case the declaration is hoisted so it can be called from earlier in the file, or assigned as expressions such as const func = function() {}, which are not hoisted. Parameters are the named variables in the function definition, while arguments are the actual values passed when calling the function; the legacy arguments object exposes every passed value. The return statement exits the function and sends a value back to the caller, and a function with no return implicitly returns undefined. Strict mode, enabled by placing the string literal 'use strict'; at the top of a script or function, enforces safer rules such as disallowing undeclared variables and duplicate parameter names.