lesson

Updated 6 days ago Β· 1 view
Imagine opening a giant box of Lego blocks with 500 pieces, but there is no instruction booklet inside!
An algorithm is a list of step-by-step instructions to solve a problem or complete a task.
πInteractive diagram
Whenever you follow a recipe, build a toy, or brush your teeth, you are following an algorithm.
What happens if you mix up the steps and do them backwards?
The Steps Must Be in Order
An algorithm only works when the steps happen in the correct sequence, which means the exact order from start to finish.
πInteractive diagram
If you put your shoes on before your socks, your socks will end up stretched over your sneakers!
How do real computers and robots use these step-by-step instructions?
Talking to Computers
Computers cannot guess what you want β they only follow exact instructions written in code.
In JavaScript, we group steps together into a function, which is a named set of instructions you can run anytime.