The Language of Programming

Learn basic concepts shared by all programming languages — values, variables, functions and control structures. Learn how changing values can change how a program works by experimenting with a JavaScript game.

Concepts

Syntax — a programming languages vocabulary and grammar. Every programming language has its own syntax. For example, JavaScript has special keywords like var, if, and function that all do different things to in a program.

Values — the data in your program. For example, a number like 375 is a numeric value; a logical value like true, or false is called a boolean value; and a collection of letters inside of quote marks are called a string: 'Hello there!'.

Variables — variables hold values. They are like boxes you store information in like the current score in a game, or the name of the player. For example, to create a variable and store a number 0 in it, you could write this JavaScript code:
var currentScore = 0

Control structures — control the flow of the program: what happens and when it happens. For example, if you're playing a game and your character dies, the game ends. The flow of the program is controlled by actions that happen in the program.

Commands (functions) — the commands we ask a program to complete, like adding two numbers together or validating a person's email address.

Downloading and Running the Project Files

Because of how the Phaser.JS library handles files, you need to be running a web server locally to view a working copy of this project. You can't just open the index.html file in your web browser as you might a basic HTML page. There are several simple ways to get a web server up and running on your computer:

The Web Server for Chrome is an easy-to-install extension for Chrome that lets you select a folder on your computer (like the folder with the game files in them) and deliver them through a basic web server. This is probably the easiest way to get started — but you'll need to use the Chrome web browser.