Lesson
1 / 7What is an Algorithm?
An algorithm is a step-by-step procedure or formula for solving a problem. In programming, it's a sequence of instructions that takes an input and produces a specific output.
script.js
// A simple algorithm to find the largest number
function max(a, b) {
return a > b ? a : b;
}An
algorithm is like a cooking recipe. You have your ingredients (input), a set of clear instructions (logic), and a finished meal (output).