---
description: What do functions look like in code?
---

# U1LA4.2: Intro to Functions && Function Calls

### Teacher Notes && Overview

**NB:** _This lesson technically covers NYS Standard **7-8.CT.4** Write a program using functions or procedures whose names or other documentation convey their purpose within the larger task. However, we know not all schools can guarantee a middle school sequence prior to this course. This lesson can be significantly abbreviated or skipped entirely based on the knowledge your students come in with!_

This lesson will continue to build onto the first lesson on abstraction by beginning to look at what functions look like in code. Students will then focus on identifying function calls and arguments/parameters within functions.

This is more of a direct lesson than the first exploratory one of this unit, so feel free to insert any structures that you think would add play and joy to an otherwise very direct practice.

### Objectives

Students will be able to:

* Identify function calls&#x20;
* Identify arguments/parameters in functions&#x20;
* Describe the purpose of having arguments/parameters in a given function

### Suggested Duration

1 Period (\~45 minutes)

### NYS Standards

**9-12.CT.4** Implement a program using a combination of student-defined and third-party functions to organize the computation.

**9-12.CT.5** Modify a function or procedure in a program to perform its computation in a different way over the same inputs, while preserving the result of the overall program.

**9-12.DL.1** Type proficiently on a keyboard.

**9-12.DL.2** Communicate and work collaboratively with others using digital tools to support individual learning and contribute to the learning of others.

### Vocabulary

* **Function call:** The name of a function, typed when you want to execute the specific steps the function represents&#x20;
* **Parameters:** The values of a function that can be controlled/altered whenever the function is called (inputs)&#x20;
* **Arguments:** Values passed through to a function’s parameters (input values)

### Planning Notes && Materials

|                                                                        Planning Notes                                                                       |                                                Materials                                                |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: |
| This is a practice-heavy, fairly low-lift lesson. Practice can be completed on paper or as a digital worksheet, depending on classroom need and preference. | <p>Practice Worksheet (digital or printed)</p><p></p><p>Post-Its/Notecards for Exit Slip (optional)</p> |

### Resources

[Functions, Parameters, and Arguments Practice](https://docs.google.com/document/d/1Os49t59t53La7-Of7cBFk4UA2bbkdXqOQsPM9ba7WmA/copy) (Worksheet)

### Assessments

**Formative:**

* Function Call Worksheet
* Exit Slip

**Summative:**

* Make an Emoji (Mini Project)
* Abstract Album Art (Final Project)

### Do Now/Warm Up (2-3 Minutes)

**Display on board:** Yesterday you learned that we can abstract procedures into functions that you can use repeatedly in your code. Based on your learning so far, what do you think a **function call** is?

### Function Calls, Arguments, and Parameters Mini Lesson (\~10 min)

Begin by asking students to share answers to the do now, getting as many different answers as possible. Once you’ve heard student ideas, explain that a function call is just what it sounds like: it’s the name we use to call a function, which is a fancy way to say ‘make it happen’ in our program.

Explain that the function call is the name, followed by parentheses, and those parentheses may have some important information inside of them. This diagram can help:

<figure><img src="https://3365989970-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6CpkJAKaYOwA5TCz4W7l%2Fuploads%2F9WvJrQPpRLWDGuPUU5pm%2Fimage.png?alt=media&#x26;token=9e36ab49-ee01-48b6-b29b-6a21a39f2ba9" alt=""><figcaption><p>Diagram of an ellipse() function with paramters/arguments/function call labeled.</p></figcaption></figure>

Explain the important parts of a function and review with an ellipse. Then explain that students will be practicing identifying function calls, parameters, and arguments. Distribute the associated worksheet and fill in the ellipse space as a class.

### Function Call Practice Worksheet (10 - 15 min)

Allow students time to complete the worksheet, either independently or with a partner or small group. One structure that may be useful in this context is Rally Coach (a Kagan Structure) where each partner folds their paper in half, and take turns coaching the other to complete a given problem on their side of the paper. It is important during this that at any given moment, only one person is writing while the other coaches - kind of like pair programming!

While students work, encourage them to get computers and use the reference sheet for anything that they may have forgotten or that they have not learned yet. Circulate and monitor progress as they work.

### Return & Review (\~10 min)

Once the majority of the class has finished, bring them together to review selected answers. It is **not** necessary to review every function on the page - it can become repetitive - but try to pick a few that are more straightforward, and a few that are more challenging. Additionally, make sure that you speak to at least one function that has no parameters and discuss that this is because the function is intended to run the same way every time as opposed to some of the others which change.

Remind students that next lesson, they will be creating their own functions. Bring their attention to the names of the functions which are all clear, concise, and do exactly what they say. This is best practice when they start writing their functions, as well!

Time permitting, you may want to preview function structure for the next lesson:

```javascript
function washHands(brand, time){
    turnOnSink()
    getSoap(brand)
    sudsHands(time)
    rinseHands()
    dryHands()
}
```

Explain that the contents of this function are pseudocode, but the structure is the same as what they will be writing. Ask what they notice and what they are curious about, and use this to both close this lesson and launch the lesson for tomorrow.

### Wrap-Up (3 - 5 min)

Consider having students write down their thoughts on what they notice about function structure, function calls, parameters, or arguments and using it as an exit slip.

### Extensions

_**There are no extensions for this activity, but if your students move quickly through it, it could be shortened to allow more time for the following, more complex activities.**_

