JavaScript for Beginners
From your first program to arrays, objects, functions, closures, classes, errors, promises and a final project.
Tests check every exercise: in your browser and in the cloud
Exercises run and are checked right in your browser, so you need nothing installed to take the course. To run the lesson examples on your own computer, set it up in two steps.
Install Node.js
The lessons use Node.js 22 or newer: pick the LTS version.
- Download the installer for your system from nodejs.org/en/download and run it.
- The guide Run Node.js scripts from the command line shows how to run a lesson's file.
Install VS Code
Download VS Code: it supports JavaScript out of the box, no extension needed.
Syllabus
- ArithmeticTheory
- Quiz — division and remainderQuiz
- Comparison and strict equalityTheory
- Quiz — == and ===Quiz
- Logical operatorsTheory
- Quiz — || and ??Quiz
- Explicit conversionTheory
- Truthy and falsy valuesTheory
- Quiz — falsy valuesQuiz
- Implicit conversionTheory
- Quiz — "5" + 3 and "5" − 3Quiz
- Exercise: leap yearExercise
- Exercise: hours and minutesExercise
- Exercise: a number or a fallbackExercise
- if and elseTheory
- switchTheory
- for and while loopsTheory
- Quiz — a sum in a loopQuiz
- break and continueTheory
- Quiz — continue and breakQuiz
- The for…of loopTheory
- The for…in loopTheory
- Quiz — for…in and for…ofQuiz
- Exercise: letter gradeExercise
- Exercise: digit sumExercise
- Exercise: count the vowelsExercise
- Exercise: prime numberExercise
- Function declarations and expressionsTheory
- Arguments and the return valueTheory
- Quiz — a missing argumentQuiz
- Default parametersTheory
- Quiz — default parametersQuiz
- Arrow functionsTheory
- Quiz — an arrow function with bracesQuiz
- RecursionTheory
- Exercise: power by recursionExercise
- Exercise: repeat a wordExercise
- StringsTheory
- Template literalsTheory
- Quiz — ${} in quotesQuiz
- Exercise: order lineExercise
- Substrings and searchTheory
- Quiz — slice and indexOfQuiz
- Transforming stringsTheory
- Comparing stringsTheory
- Quiz — "10" < "9"Quiz
- Exercise: which word comes firstExercise
- Exercise: reverse a stringExercise
- Exercise: palindromeExercise
- ArraysTheory
- Adding and removingTheory
- Quiz — what push returnsQuiz
- slice and spliceTheory
- Quiz — slice and spliceQuiz
- Finding an elementTheory
- An array is a referenceTheory
- Quiz — two names for one arrayQuiz
- Rest parametersTheory
- Exercise: reversed arrayExercise
- Exercise: record positionsExercise
- Exercise: without a valueExercise
- Exercise: insert into an arrayExercise
- A function as an argument: forEachTheory
- map and filterTheory
- Quiz — filter, then mapQuiz
- reduceTheory
- Quiz — map, filter, reduce, forEachQuiz
- find, some and everyTheory
- SortingTheory
- Quiz — sort without a functionQuiz
- Exercise: sum of even squaresExercise
- Exercise: the longest wordExercise
- Exercise: checking agesExercise
- Exercise: top three scoresExercise
- ObjectsTheory
- Quiz — dot and bracketsQuiz
- Iterating over an objectTheory
- Quiz — key orderQuiz
- Methods and thisTheory
- ShorthandTheory
- Copying an objectTheory
- Quiz — a shallow copyQuiz
- DestructuringTheory
- Optional chainingTheory
- Exercise: word countExercise
- Exercise: default settingsExercise
- Exercise: who and where fromExercise
- ClassesTheory
- Getters and settersTheory
- Quiz — a getterQuiz
- Private fields and staticTheory
- InheritanceTheory
- Quiz — an overridden methodQuiz
- The prototype chainTheory
- Quiz — the prototype chainQuiz
- Exercise: bank accountExercise
- Exercise: durationExercise
- Exercise: temperatureExercise
- Exercise: shapesExercise
- setTimeout and callbacksTheory
- Quiz — order with setTimeoutQuiz
- PromisesTheory
- Quiz — promise statesQuiz
- Promises before timersTheory
- Quiz — a promise and setTimeoutQuiz
- async and awaitTheory
- Quiz — async functionsQuiz
- Exercise: retry an async taskExercise
- Several promises at onceTheory
- Quiz — the order of Promise.all valuesQuiz
- Exercise: a promise with a time limitExercise