
# Coaching - Methods 2
with Founders and Coders
---
JavaScript Methods act like functions built into JavaScript.
----
Methods give us the ability to do complex things with relatively little code.
---
## Array Methods
----
We've seen some array methods already, like `join()` and `pop()`.
----
Some array methods allow us to alter *each* element within an array.
----
Can you think of some things we might like to do to each element in an array of numbers?
----
Can you think of some things we might like to do to each string in an array?
---
### `map()`
### :world_map:
----
Creates a new array with the result of calling a function for each array element
----
```javascript=
array.map(function(currentValue, index, arr){
// What your function does here
});
```
----
[Replit](https://replit.com/@Albadylic/BarrenVerticalEngines#index.js)
---
### `filter()`
:hourglass_flowing_sand:
----
Creates a new array with all the elements that fulfil a condition passed via a function.
----
```javascript=
array.filter(function(currentValue, index, arr)){
// Our condition here
}
```
----
[Replit](https://replit.com/@Albadylic/BarrenVerticalEngines#index.js)
---
### `reduce()`
:deciduous_tree: :arrow_right: :seedling:
----
The reduce method converts the values in an array into a single value.
----
```javascript=
array.reduce(function(total, currentValue, currentIndex, arr), initialValue){
// Code to reduce the values
}
```
----
[Replit](https://replit.com/@Albadylic/BarrenVerticalEngines#index.js)
{"metaMigratedAt":"2023-06-15T21:46:51.839Z","metaMigratedFrom":"YAML","title":"Coaching - Methods 2","breaks":true,"slideOptions":"{\"theme\":\"white\"}","contributors":"[{\"id\":\"2967aacf-1990-431e-b963-91e79ce4a2bf\",\"add\":1717,\"del\":73}]"}