What are arguments and why should I care?

In programming, an argument does not have anything at all to do with with loud voices or disagreement.

In programming an argument is something that is sent as input to a function call

The stuff you see between the parentheses in a function call is the arguments. The arguments is received by the function and will determine the way that the action of the function is carried out.

Let's try it out

1

Type the following into the the box where it says Enter source code here:

turnOn(2);
turnOff(2);
2

Click Check source code.

3

Click Run!.

So what is happening here?

The functions turnOn() and turnOff() are taking one argument each - a number identifying the lamp to turn on and off respectively. When called, the functions will turn on or off the lamp given by the argument.

Now, for fun. Try this:

1
2
3
4
5
6
7
8
turnOn(0);
turnOn(1);
turnOn(2);
turnOn(3);
turnOff(0);
turnOff(1);
turnOff(2);
turnOff(3);
Next lesson:
Strings
What are strings?