<commit_before># Functions and Scope in JavaScript

Functions are a data type that take input and output values based on their input.

Functions let you break larger projects up into smaller pieces. They also help you to not repeat yourself. You define a function once and use it in many different places.

## Arguments

Functions can take one or more arguments. Each argument will change the output of the function when it returns.

## Example

This example function just adds two numbers together and returns the result.

```js
function addNumbers(a, b) {
  return a + b;
}
```

Once a function is defined you need to call it. To call a named function you just invoke its name with parentheses, filling in any arguments it might require like this:

```js
// Call addNumbers function
var result = addNumbers(2, 2);
```

The above will store the result of `addNumbers` to the variable `result`. It is common to store the return values of functions in a variable so you don't have to run the function each time you need to get it's return value.

## Functions Exercise

__The Fortune Teller Game__

Write a function named `tellFortune` that:

- Takes 4 arguments: number of children, partner's name, geographic location, job title.
- Tutputs your fortune to the screen like so: "You will be a X in Y, and married to Z with N kids."
- Call that function 3 times with 3 different values for the arguments.

## Homework

You can find the instructions for homework in [the class Homework repository for week 2](https://github.com/ga-chicago/wdi5-homework) on GitHub.<commit_msg>fixxed merge<commit_after># Functions and Scope in JavaScript

Functions are a data type that take input and output values based on their input.

Functions let you break larger projects up into smaller pieces. They also help you to not repeat yourself. You define a function once and use it in many different places.

## Arguments

Functions can take one or more arguments. Each argument will change the output of the function when it returns.

## Example

This example function just adds two numbers together and returns the result.

```js
function addNumbers(a, b) {
  return a + b;
}
```

Once a function is defined you need to call it. To call a named function you just invoke its name with parentheses, filling in any arguments it might require like this:

```js
// Call addNumbers function
var result = addNumbers(2, 2);
```

The above will store the result of `addNumbers` to the variable `result`. It is common to store the return values of functions in a variable so you don't have to run the function each time you need to get it's return value.

## Functions Exercise

__The Fortune Teller Game__

Write a function named `tellFortune` that:

- Takes 4 arguments: number of children, partner's name, geographic location, job title.
- Tutputs your fortune to the screen like so: "You will be a X in Y, and married to Z with N kids."
- Call that function 3 times with 3 different values for the arguments.


{'fraction_non_alphanumeric': 0.05321285140562249, 'fraction_numerical': 0.004016064257028112, 'mean_word_length': 4.109401709401709, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1845811', 'n_tokens_mistral': 791, 'n_tokens_neox': 739, 'n_words': 478}