> For the complete documentation index, see [llms.txt](https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/glossary-and-terms/functions-and-methods/parameters-and-arguments.md).

# Parameters & Arguments

Parameters and arguments are basically the input required and used by functions.

Think of it this way…

Say you have a bunch of random colored blocks. You don't know how many or what order.

You want to turn the red blocks green.

You can go through each block and use code to say "if red, turn green" but if the code to turn it green is complicated, separate it into a function.

```java
void turnGreen() {
	// code for a block to turn green
}
```

But how does the function know **what block** to&#x20;turn green?

One way we can say which block is by adding parameters to our function, then using arguments when calling it.

```java
void turnGreen(block blockToChange) {
	// code for blockToChange to turn green
}
```

The parameter **`blockToChange`** becomes a&#x20;temporary variable and only can be used for&#x20;this function.

So when we call it, we can say what block it is by putting it as&#x20;an argument...

```java
if (block15 is Red) {
		turnGreen(block15);
}
```

block15 is sent to the function, setting&#x20;**`blockToChange`** to `block15`.

Say you want to turn multiple specific blocks to a specific color. You can use parameters and arguments to get information and use it in the function.

```java
void changeColor(block blockToChange, color newColor) {
	// code for blockToChange to change to the new color
}
```

The parameters **`blockToChange`** and **`newColor`** become temporary variables and only can be used for this function.

So when we call the function, we can say what block and what color by using arguments...

```java
changeColor(block11, grey);
```

block11 and grey is sent to the function,&#x20;setting **`blockToChange`** to `block11` and&#x20;**`newColor`** to `grey` so the function knows to set block11 to grey. Then, any other blocks and colors can be used without extra or repeated code.
