← All subjects
NewFree preview available
Coding · Any age, any level

JavaScript from Beginner to Advanced: Make Pages Interactive

Learn to program with JavaScript, the language of the web: variables, decisions, loops, functions, arrays and objects, then real interactive pages and a to-do list app.

★ New0 reviews1 learners
Created by GradesPal
Modules
3
Lessons
15
Study time
8h 15m

What you’ll learn

Write programs with variables, decisions, loops and functions
Store and process data with arrays and objects
Read and fix error messages calmly
Make web pages react to clicks and typing
Check forms, save data in the browser and work with JSON
Build and download a working to-do list app

Workshop content

3 modules · 15 lessons · 8h 15m total

Level 1 · Beginner5 lessons
Your first program30 min · Preview

Your first program

JavaScript4 min readTry it live: Code Studio

In this lesson

  1. What is a program?
  2. Printing to the Console
  3. One instruction per line
  4. Comments
  5. Errors are normal
  6. Where JavaScript lives

Practise this in the Code Studio

open the exercise for this lesson. You type real code in your browser, see the result at once, and the tasks tick themselves when your code is right. Nothing to install.

HTML builds a page and CSS styles it. JavaScript makes it do things: react to a click, check a form, add up a total, load new posts. It is the programming language of the web, and it runs in every browser.

Note

JavaScript and Java are two different languages with similar names. JavaScript runs in the browser; Java is used for other kinds of programs. GradesPal has a separate Java course.

What is a program?

A program is a list of instructions. The computer follows them one at a time, from top to bottom, exactly as written. It never guesses what you meant.

Printing to the Console

JavaScript
console.log("Hello, world!");
PartMeaning
console.log"Print this in the Console"
( )Brackets hold what to print
"Hello, world!"Text, in quotes
;The end of the instruction

The Console is a panel where a program can write messages. Visitors to a website never see it; programmers use it all day to check what their code is doing. In the Code Studio it is the Console tab below the editor.

One instruction per line

JavaScript
console.log("Hello, world!");
console.log("My name is Thabo");
console.log(7 * 6);

This prints three lines, in order. Notice the last one: numbers have no quotes, and JavaScript works out the answer, 42.

You writeIt printsWhy
console.log(7 * 6);42A calculation
console.log("7 * 6");7 * 6Quotes make it text, so nothing is calculated

Comments

JavaScript
// This line is a comment
console.log("Hi"); // a comment after some code

/* A comment
   over several lines */

The computer ignores comments. Write them to explain why your code does something. Your future self will thank you.

Errors are normal

Every programmer, at every level, makes mistakes all day long. An error message is not a failure; it is the computer telling you where to look.

JavaScript
console.log("Hello);

The closing quote is missing. The Console shows a red message with a line number. Go to that line and read it slowly.

Common slipLooks like
A missing quoteconsole.log("Hello);
A missing bracketconsole.log("Hello";
A wrong capital letterConsole.Log("Hello");

JavaScript is case-sensitive: console and Console are different words.

Where JavaScript lives

In a real page, JavaScript goes in its own file, linked at the bottom of the body:

HTML
<script src="script.js"></script>

In the Studio, the script.js tab is that file.

Try it

  1. Print your name, your grade and your favourite subject on three lines.
  2. Print the answer to 365 × 24 (the number of hours in a year).
  3. Break your code on purpose: remove a quote, then a bracket. Read each error, then fix it.
  4. Add a comment above each line saying what it does.

Check yourself

What does console.log("5 + 5"); print?

It prints 5 + 5. The quotes make it text. Without quotes, console.log(5 + 5); prints 10.

Why does Console.log("Hi"); give an error?

JavaScript is case-sensitive. The word is console, with a small c, and log with a small l.

In what order does a program run?

From the top to the bottom, one instruction at a time.

Practise this lesson in the Code Studio →

Variables and data types30 min
Operators and maths30 min
Making decisions30 min
Loops30 min
Level 2 · Intermediate5 lessons
Functions30 min
Arrays30 min
Objects30 min
Changing the page: the DOM30 min
Events30 min
Level 3 · Advanced5 lessons
Array methods30 min
Forms and validation30 min
JSON and saving data30 min
Waiting: timers, promises and async30 min
Project: a to-do list app75 min

Requirements

  • Any device with a web browser: a computer is best
  • No programming experience needed
  • Basic HTML and CSS help from Lesson 9 onwards
  • Open to everyone: no age or grade requirement

Frequently asked questions

Do I need to install anything?

No. You write and run all your code in the GradesPal Code Studio, in your browser. It works on a computer, a tablet or a phone, though a keyboard makes typing code much easier.

Can I buy only one level?

Yes. The course has three levels: Beginner, Intermediate and Advanced. You can buy the whole course or one level at a time.

How long does it take?

There are 15 lessons. Working about an hour a day, most learners finish in three to four weeks, but you can go at your own speed.

Who is this course for?

Anyone. The course starts from zero, so it suits school learners, university students and adults changing careers or learning for fun. There is no grade or age requirement.

Will I get a certificate?

Yes. Finish the lessons and the project to complete the course.

No reviews yet