Find a course
Age level: Teens (12–18)BeginnerTechnology & Programming

Make Games with JavaScript

Code real browser games with variables, loops, canvas drawing, keys and collisions

⏱ 2 h5 modules · 11 lessons58 practice questionsFinal exam: 20 questions
First name and initial are enough.
Included with this course

Your certificate for this course

Finish the 11 lessons (about 2 h) and pass the 20-question final exam. Your Certificate of Completion is ready the moment you pass.

  • Your name and this course titlePrinted in classic diploma typography
  • Grade: Pass, Merit or DistinctionOn the gold seal, with your final score
  • Unique ID and QR codeAnyone can verify it in seconds
  • Score report PDFModule-by-module results and exam score
  1. Lessons11 lessons
  2. Final exam20 questions · 70% to pass
  3. CertificatePDF + score report

What you will learn

  • Store and update game state such as score, lives and position with variables
  • Write game rules with if, else and comparison operators
  • Use loops and functions to keep game code short and reusable
  • Manage players, enemies and high scores with arrays and objects
  • Draw shapes on an HTML canvas using its coordinate system
  • Animate objects with a game loop, velocity and wall bounces
  • Handle keyboard input, detect collisions and use randomness to build a complete game

About this course

Every game you have ever played, from a simple snake game to a huge open world, runs on the same core ideas: numbers that remember the state of the game, rules that check what's happening, a loop that runs many times per second, and code that reacts when you press a key. This free course teaches you those ideas by using them to build games that run in a web browser.

You'll use JavaScript, the language built into every browser, so there's nothing to buy and almost nothing to install. You'll start with variables for score and lives, then write the rules of a game with if statements. Next you'll learn loops and functions, the tools that keep game code short, and arrays and objects for storing players, enemies and high scores.

Then the fun part: drawing on an HTML canvas, understanding why the y axis points down, and making things move smoothly with an animation loop. You'll add keyboard controls, detect when two objects collide, use randomness to spawn enemies and power-ups, and wire it all together into a complete catch-the-falling-stars game with a score and a game-over screen.

The course is designed for teens who are new to coding, though anyone who wants a playful start is welcome. Every lesson includes small coding challenges you solve right on the page, with automatic tests that tell you if your code works, plus quick checks that make sure the ideas stick. Pass the final exam to earn a free certificate of completion and keep building your own games.

Syllabus

  1. Game State and Rules

    Learn how games remember things with variables and decide what happens with if statements and comparisons.

    1. Variables for Score, Lives and More11 min
    2. If Statements and Game Rules12 min
  2. Loops and Functions

    Repeat actions without copying code, and package game actions into reusable functions with inputs and return values.

    1. Loops That Repeat12 min
    2. Functions for Game Actions12 min
  3. Arrays and Objects

    Store many things at once with arrays and describe game characters with objects, the two data structures every game is built on.

    1. Arrays for Enemies, Items and High Scores12 min
    2. Objects for Players and Enemies12 min
  4. Drawing and Motion

    Draw shapes on an HTML canvas, understand its upside-down coordinate system, and make things move with a game loop, velocity and gravity.

    1. Drawing on the Canvas12 min
    2. The Game Loop and Animation14 min
  5. Input, Collisions and a Full Game

    Let players steer with the keyboard, detect when objects touch, add randomness, and assemble everything into a finished game with a score and game over.

    1. Keyboard Controls12 min
    2. Collision Detection13 min
    3. Randomness, Score and Game Over14 min
  6. Final exam and certificate

    20 questions drawn from a pool of 33. Score 70% or more to pass; retakes get a fresh set of questions.

Try a sample question

In JavaScript, the line x = x + 1 is a mistake because x can never equal x + 1.

True or false?

Show the answer

Answer: False

A single equals sign means assignment, not equality. The line calculates x + 1 and stores it back in x, which increases x by one. Comparing for equality uses three equals signs, which you'll meet in the next lesson.

Variable
A named box that stores a value, such as a score, that the program can read and change.
let
A JavaScript keyword that creates a variable whose value can change later.
const
A JavaScript keyword that creates a variable that cannot be reassigned.
Boolean
A value that is either true or false, used for yes-or-no game state such as isGameOver.
Condition
An expression that is true or false and decides whether an if block runs.
Loop
Code that repeats, such as a for loop that runs once for each enemy.

Frequently asked questions

Do I need to know HTML before learning JavaScript games?

Only a tiny bit. A canvas game needs one short HTML file with a canvas element and a script tag, and this course shows you that file. Everything else happens in JavaScript.

Is JavaScript a good first language for making games?

Yes, especially for 2D games. It runs in every browser, you see results instantly, and sharing a game is as easy as sending a link. Professional studios often use other languages for big 3D games, but the core ideas you learn here, like game loops and collision checks, carry over to any language or engine.

What do I need to install?

Just a web browser and a text editor. A free code editor such as Visual Studio Code makes life easier, and online playgrounds let you code games without installing anything at all.

How is this different from block coding like Scratch?

Scratch is great for learning logic with drag-and-drop blocks. JavaScript is typed text, which is what professional developers use. If you've used Scratch, you'll recognize loops, if blocks and variables; here you'll write them yourself and gain much more control.

Can I make money from games I build in JavaScript?

Many people publish browser games on game portals or turn them into mobile apps with extra tools. Start by finishing small games and sharing them with friends; finishing a game is the skill that matters most.

What should I learn after this course?

Try adding sound, sprite images and levels to your game, then explore a beginner-friendly game framework such as Phaser. Learning more about functions, arrays and objects will make every bigger project easier.

Sources and further reading

Related courses

Adults & professionalsBeginner

JavaScript for Beginners

Variables, functions, arrays, objects, the DOM and async code

Technology & Programming
2 h 10 min12 lessonsCertificate
TeensBeginner

Python for Teens

Write real programs: games, quizzes and calculators from your first line of code

Technology & Programming
1 h 55 min10 lessonsCertificate
KidsBeginner

Coding for Kids

Algorithms, loops, if-then, variables and bug hunting, then write real JavaScript

Technology & Programming
1 h7 lessonsCertificate
Adults & professionalsBeginner

Python for Beginners

Write real programs with variables, loops, lists, dictionaries and functions

Technology & Programming
2 h 15 min12 lessonsCertificate
University studentsIntermediate

Regular Expressions

Match, extract and replace text with regex in JavaScript, Python and your editor

Technology & Programming
2 h 45 min12 lessonsCertificate
Adults & professionalsBeginner

Git and GitHub Basics

Track changes, branch safely and collaborate with pull requests

Technology & Programming
2 h12 lessonsCertificate