> For the complete documentation index, see [llms.txt](https://program.hackyourfuture.dk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://program.hackyourfuture.dk/course-content/backend/advanced-javascript/week1.md).

# Week 1

Array methods are the Logic layer's core tools. Every backend request involves transforming data: filtering results, mapping to response formats, reducing to totals. These operations happen on nearly every request.

This week you'll learn the three essential methods: `forEach`, `map`, and `filter`. You'll understand when to use each one, and how they fit into the Data → Logic → Rendering model.

## Contents

* [Preparation](/course-content/backend/advanced-javascript/week1/preparation.md)
* [Slides](https://github.com/HackYourFuture-CPH/program/blob/main/courses/backend/advanced-javascript/week1/session-materials/slides/index.html)
* [Session Plan](/course-content/backend/advanced-javascript/week1/session-plan.md) (for mentors)
* [Session Materials](https://github.com/HackYourFuture-CPH/program/blob/main/courses/backend/advanced-javascript/week1/session-materials/README.md)
* [Assignment](/course-content/backend/advanced-javascript/week1/assignment.md)

## Learning Goals

By the end of this session, you will be able to:

* [ ] Use `forEach` for side effects (logging, rendering)
* [ ] Use `map` to transform arrays (N items → N transformed items)
* [ ] Use `filter` to select items (N items → fewer items, same shape)
* [ ] Combine multiple array methods through chaining
* [ ] Use arrow function syntax with implicit and explicit returns
* [ ] Recognize which methods belong in the Logic layer vs Rendering layer
* [ ] Know how to find and learn about other array methods such as `.find()`, `.some()`, `.reduce()`

### After this session you will understand code like this

```js
// Example: Get names of organic Japanese teas
const result = teas
  .filter((tea) => tea.origin === "Japan")
  .filter((tea) => tea.organic)
  .map((tea) => tea.name);
// ["Sencha", "Matcha"]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://program.hackyourfuture.dk/course-content/backend/advanced-javascript/week1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
