Skip to content

Commit

Permalink
Make new lesson for m2 iterator practice
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylagordon committed Mar 21, 2024
1 parent d03a728 commit 2f220ce
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions lessons/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ <h4>General</h4>
<li class="lesson"><a href="module-2/context-and-this-keyword.html">Context and "this" keyword</a></li>
<li class="lesson"><a href="module-2/asynchronous-javascript.html">Asynchronous JavaScript</a></li>
<li class="lesson"><a href="module-2/intro-to-destructuring.html">Intro to Destructuring</a></li>
<li class="lesson"><a href="module-2/approaching-problems-many-ways.html">Approaching Problems Many Ways</a></li>
</ul>

<h4>Objects</h4>
Expand Down
51 changes: 51 additions & 0 deletions lessons/module-2/approaching-problems-many-ways.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Approaching Problems Many Ways"
length: 60
tags: prototype methods
---

## Learning Goals
- Develop a deeper understanding of iterator methods
- Reduce the risk of being too attached to one iterator method OR avoiding an iterator method
- Compare and contrast iterator methods by using different iterators to achieve the same output

## Activity

### Set Up
- Fork [this replit]()
- We will be solving the same challenge three times today. Each time, you will be told with iterator method(s) you're allowed to use.

### Round 1: `forEach`
- Solve the prompt using a `forEach`. You may not use any other iterator methods.

<section class="call-to-action">
### Round 1 Reflection

- What are some pros and cons of using `forEach`?
- Can you think of any prompt/scenario where a `forEach` would not work?
</section>

### Round 2: `filter` and `map`
- Solve the prompt using a `filter` and `map`. You may not use any other iterator methods.

<section class="call-to-action">
### Round 2 Reflection

- What are some pros and cons of this approach?
- Why couldn't we use only a `filter` or only a `map`? Why did we need to use both?
</section>

### Round 3: `reduce`
- Solve the prompt using a `reduce`. You may not use any other iterator methods.

<section class="call-to-action">
### Round 3 Reflection

- What are some pros and cons of using `reduce`?
- Can you think of any prompt/scenario where a `reduce` would not work?
- Look at your code from the `forEach` and `reduce`. How do they compare?
- Out of all 3 rounds, which approach did you prefer? Why?
</section>

## Looking Ahead
While you are working on jsFUN, we recommend taking the time to solve the same problem multiple ways. This will reduce the likelihood that you become too attached or too afraid of an iterator method. It can also help to understand each method better if you are comparing them to each other. Remember that jsFUN is there to help you learn - finishing the problems as fast as you can is not the goal!

0 comments on commit 2f220ce

Please sign in to comment.