Lessons · JavaScript
Learn JavaScript step by step: 9 lessons with runnable examples
Each lesson pairs a plain-English explanation with code you can run. Every example was executed through the same sandbox the playground uses before it was published, so what you read has been checked, not just typed.
Lesson 1
JavaScript Printing and Output
Learn what console.log really does in JavaScript - string concatenation with +, template literals, printing multiple values, and the escape sequences you will use constantly.
console · output · basics
Lesson 2
JavaScript Variables and Data Types
Understand let and const, JavaScript's primitive types, and how typeof, undefined, and null behave when you check and convert values.
variables · data-types · basics
Lesson 3
JavaScript Arithmetic and Numbers
How JavaScript does math - why there is only one number type, what the remainder operator really answers, powers, the Math object, and why 0.1 + 0.2 is not 0.3.
arithmetic · numbers · operators · math
Lesson 4
JavaScript Strings
Learn how JavaScript strings are created, why they are immutable, how indexing and slicing work, and the string methods you will use most, including padStart and padEnd for alignment.
strings · text · template-literals
Lesson 5
JavaScript Conditionals: if, else if, and else
Learn how JavaScript makes decisions with if, else if, and else, the difference between === and ==, truthiness, and the ternary operator.
conditionals · control-flow · booleans
Lesson 6
JavaScript Arrays
Learn how JavaScript arrays store ordered, changeable lists of values, and how to create, access, modify, search, sort, and transform them with push, map, and filter.
arrays · data-structures
Lesson 7
JavaScript Objects
Learn how JavaScript objects pair keys with values, read them safely with optional chaining, add, update, and delete properties, loop with Object.entries, and why lookups are fast.
objects · data-structures · hash-tables
Lesson 8
JavaScript For Loops and Iteration
Learn JavaScript loops from the ground up - the classic for loop, for...of, the forEach array method, getting both index and value with entries, and steering a loop with break and continue.
loops · iteration · control-flow
Lesson 9
JavaScript Functions: Declaring, Calling, and Returning
Learn JavaScript functions from scratch - function declarations, arrow functions, parameters and default values, return values, and local versus global scope.
functions · arrow-functions · scope
Reading is half of it
The JavaScript exercises are where you write the code these lessons describe, one idea at a time, with the output checked for you. The playground is for trying any example on this page with your own numbers.