Web Foundations — Student Examples

Every example from class, in the order we learn it. Open a file, read the comments, change something, and see what happens.

⬇ Download all files (zip) Unzip it, open the folder in VS Code, and run the .js files with node.

Step 1

JavaScript

12 lessons · run each file with Node in the terminal.

Step 1b

JS Practice

10 programs that use all of JavaScript together.

Step 2

CSS

18 lessons · open the page in the browser, edit the .css next to it.

Step 3

DOM

16 lessons · JavaScript that changes the page. Uses both!

0Before you start

Keep the VS Code shortcuts page open in another tab. It shows how to open a folder, use the terminal and edit faster.

Every lesson below opens in a new tab. When you finish, close that tab and you are back on this page.

1JavaScript

How to run a lesson
  1. Open the Learn-With-Examples folder in VS Code and open the terminal (Ctrl + `).
  2. Go into the folder: cd JavaScript
  3. Run a file: node "01 - console.js" (the quotes are needed because the name has spaces).
  4. Read the comments in the file — the // Output: lines tell you what you should see.
Each lesson ends with a Quick summary and Practice tasks. Do the tasks before moving to the next file.

1bJavaScript practice — 10 must-do programs

After lesson 12, write these 10 programs yourself
  1. Read how to practise first.
  2. Each file has a story, the rules, the data, and STEPs. Write your code under each STEP.
  3. Run it: cd JavaScript-Practice then node "01 - fee-receipt.js". Compare with the expected output at the bottom.
  4. When your output matches, show it to your trainer. Solutions are shared after class.
Each program uses everything before it, plus one new idea. Programs 09 and 10 use every concept from lessons 01–12.

2CSS

How to use a lesson
  1. Each lesson is a folder. Each example inside it is a pair: 01-name.html + 01-name.css.
  2. Open the .html file in the browser (double-click it).
  3. Open the .css file with the same name in VS Code. Read the comments and the Try it: lines.
  4. Change a value, save (Ctrl + S), and refresh the browser (F5).
Pictures used by the examples are in CSS/assets. Do not move or rename them, or the pages will lose their images.

3DOM — JavaScript in the page

How to use a lesson
  1. Each example is three files with the same name: .html + .css + .js. The .js file is the lesson — read it first.
  2. Open the .html in the browser, then press F12 and click Console to see the messages it prints.
  3. Pages with see in the name are teaching animations: press Step ▶ (or →) to watch the browser work one step at a time.
  4. Edit the .js, save, refresh. You never need to open the assets folder — it only runs the animations.