From 2884dec2838b3e556eea87361d0a5f6b8f8c678b Mon Sep 17 00:00:00 2001 From: Kayla Wood Date: Thu, 21 Mar 2024 11:49:31 -0600 Subject: [PATCH] Add example to iterators practice --- .../approaching-problems-many-ways.md | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/lessons/module-2/approaching-problems-many-ways.md b/lessons/module-2/approaching-problems-many-ways.md index 8c72e4e0..cd2a1e25 100644 --- a/lessons/module-2/approaching-problems-many-ways.md +++ b/lessons/module-2/approaching-problems-many-ways.md @@ -12,9 +12,47 @@ tags: prototype methods ## Activity ### Set Up -- Fork [this replit]() +- Open up a new replit. +- Here is your starter code for your replit: +```js +const ninetiesToys = [ + { + name: "Tamagotchi", + releaseYear: 1996, + price: 15.99 + }, + { + name: "Furby", + releaseYear: 1998, + price: 29.99 + }, + { + name: "Super Soaker", + releaseYear: 1989, + price: 19.99 + }, + { + name: "Pogs", + releaseYear: 1991, + price: 5.99 + }, + { + name: "Game Boy", + releaseYear: 1989, + price: 89.99 + } +]; +``` - 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. +
+### The Prompt! + +Write a function `findCheapToys` that returns an array of toy names that cost less than $20. + +Expect output => `[ 'Tamagotchi', 'Super Soaker', 'Pogs' ]` +
+ ### Round 1: `forEach` - Solve the prompt using a `forEach`. You may not use any other iterator methods.