scrimba
Learn JavaScript loops and iteration
map and filter: returning a new array
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

map and filter: returning a new array
AboutCommentsNotes
map and filter: returning a new array
Expand for more info
index.js
run
preview
console
/* Example: .map() */

let clothes = [
{
item: "top",
isClean: true,
},
{
item: "underwear",
isClean: false,
},
{
item: "bottoms",
isClean: false,
},
{
item: "socks",
isClean: true,
},
{
item: "shoes",
isClean: true,
},
]

/* Challenge: Washing dirty clothes

1. Create a variable called washingClothes
2. Filter through the clothes array and select the item that is dirty
3. Use map() method to create a new array which contains "Washing [item]" for each item in the array
4. Console log the new washingClothes array

*/

Console
[
"Washing underwear"
,
"Washing bottoms"
]
,
/index.html
-4:11