JavaScript

The language of the web: from your first console line to a complete web page. Take the lessons in order; each one has a short explanation, runnable examples and practice with instant checking.

Baccalaureate Lessons marked “Baccalaureate” cover the 2nd-year Baccalaureate curriculum.

Getting started

  1. 1Printing to the consoleWrite your first program that prints text, see what an error looks like, and leave notes with comments.
  2. 2Calculations and textMake the computer calculate with + - * / %, and join text with calculation results in one line.
  3. 3VariablesStore values in variables with let, change them, and use them in calculations and printed sentences.

Making decisions

  1. 4Decisions: if and elseMake a program run some lines only when a condition is true, and other lines when it is not.
  2. 5Comparison and logical operatorsWrite conditions such as “greater than” and “not equal”, and combine two conditions into one with && and ||.
  3. 6else if chainsChoose between more than two cases with an if / else if / else chain, and order the conditions so the right one runs.
  4. 7The switch statementChoose between many values of one variable with a switch statement instead of a long else if chain.
  5. 8Grouping cases and negationGroup switch cases that share a result, share things out in turn with the remainder, and flip a condition with !.Baccalaureate

Loops

  1. 9Repeating with forRepeat commands a set number of times with a for loop, and use its counter inside.
  2. 10Repeated calculations and nested loopsAdd and multiply with a for loop, run a command on a chosen round with if, and put a loop inside a loop.
  3. 11The while loopChoose between let and const, use !=, and repeat a task as long as a condition is true with a while loop.
  4. 12while (2): conditions inside loops and continuePut an if statement inside a while loop, and skip the rest of the current turn with continue.Baccalaureate

Functions

  1. 13Built-in Math functionsUse the ready-made Math functions to round, drop fractions, find the largest and smallest value, and make random numbers.
  2. 14Making your own functionsCreate a function with parameters and a return value, call it, and know where a variable can be used (scope).
  3. 15Functions in practiceWrite functions with several parameters, store their result in a variable, and put loops, conditions and the remainder operator inside them.Baccalaureate

Arrays

  1. 16Data types and arraysFind the type of any value with typeof, store many values in one array, and read or change them by their position.
  2. 17Arrays with loops and for...ofGo through every value of an array with a for loop or for...of, and work out totals, averages and how many values meet a condition.Baccalaureate
  3. 18Arrays: index, for...of and length togetherCombine the index, for...of and length in one program, and find the largest and smallest values yourself.Baccalaureate
  4. 19Array operations (1): includes, indexOf, sort, reverseCheck whether a value is in an array and where it is, and sort or reverse an array with ready-made operations.Baccalaureate
  5. 20Array operations (2): push, pop, shift, unshiftAdd values to the start or end of an array and remove them, without rewriting the array.Baccalaureate

Web pages

  1. 21HTML basicsBuild a simple web page with headings, paragraphs, lists and pictures using HTML tags.
  2. 22CSS basicsChange a web page's colours, font size, weight and alignment with CSS rules, and target chosen elements with classes.
  3. 23span, buttons and bordersStyle part of a line with span, add input fields and buttons, change their look on mouse-over, and draw borders around elements.
  4. 24CSS colours and opacityWrite colours as numbers with RGB and hex codes, and make elements see-through with opacity.Baccalaureate
  5. 25Building a websiteCombine HTML and CSS to build a complete cafe page split into a header, main content and footer, and style each part on its own.Baccalaureate