Programming logic
Stage 1 of Programming14 lessons
The building blocks of any program. From 1.1 to 1.6, in pseudocode, so you can think without fighting a language; from 1.7 to 1.14, in JavaScript, in the browser console, up to a whole game. One idea per lesson, each with its exercise and solution.
Lesson 1.1: What a program is
A program is a list of instructions. The computer follows them one by one, in order, and guesses nothing.
Lesson 1.2: Algorithms and pseudocode
Before writing code you need to know which steps to take. That is an algorithm, and pseudocode is how you write it down.
Lesson 1.3: Data and variables
A program works with data. To use it, it keeps it in variables: boxes with a name.
Lesson 1.4: Deciding: conditions
A program doesn't always do the same thing. With a condition it chooses what to do based on the data.
Lesson 1.5: Repeating: loops
If something repeats, you don't write it ten times. You write it once inside a loop.
Lesson 1.6: Functions
A function is a named piece of a program. You write it once and use it as many times as you need.
Lesson 1.7: From pseudocode to JavaScript
JavaScript is a real language and it's already in your browser. The ideas are the pseudocode ones; the words change.
Lesson 1.8: Variables and types in JavaScript
The named boxes from 1.3, now in JavaScript: how to create them, which types exist and a trap worth knowing early.
Lesson 1.9: Conditions and loops in JavaScript
Deciding and repeating, like in 1.4 and 1.5. In JavaScript what's inside goes between curly braces.
Lesson 1.10: Functions in JavaScript
The functions from 1.6, written in JavaScript: function to define one and return to give back a result.
Lesson 1.11: Arrays
An array keeps several values in order, in a single variable.
Lesson 1.12: Objects
An object groups the data of one thing, each piece with its own name.
Lesson 1.13: Debugging
A program almost never works the first time. Debugging is finding out why, and there's a method to it.
Lesson 1.14: Project: guess the number
A whole game with everything from this stage: variables, conditions, loops and functions.