Sample Video Frame

Created by Zed A. Shaw Updated 2024-02-17 04:54:36

11: Functions

You will now learn about the concept of a function. This concept can get very complex in JavaScript, but I'm going to start you off with two simple versions of the function, and then have you drill them until you get them. It's very important that you read this exercise. Functions are about movement inside code, so try drawing these motions out on paper to visualize what's going on.

A Short History of The Jump

To explain functions I'm first going to take you through a walk down a tiny history of computers, and at the end functions will make more sense.


When you run your JavaScript code it starts at the first line and goes to the last line. The computer just takes each line, processes it, and then moves to the next one. This isn't very useful though because the power of a computer comes from doing two more things:

  1. Making decisions, also called "branches".
  2. Repeating some piece of code over and over, also called "a loop".

In the old days there was a language called BASIC, and it had this thing called a GOTO:

Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.