Procedural programming

An imperative programming paradigm based on a sequence of procedures to achieve a specific task. It uses variables, loops, and conditional statements for control flow.


Example

function setArea(rect) {
  rect.area = rect.width * rect.height;
}
const rect = { width: 5, height: 2 };
setArea(rect);
rect.area;
10
function makeSquare(size) {
  return {
    width: size,
    height: size
  };
}
const square = makeSquare(6);
setArea(square);
square.area;
36

External Resources