scrimba
Note at 0:48
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

Note at 0:48
AboutCommentsNotes
Note at 0:48
Expand for more info
index.js
run
preview
console
const dangerArray = [
["🎅", "👺"],
[
["🎅", "🦁"],
["👹", "🎅"]
],
[
[
["🎅", "🐻"],
["🧌", "🎅"]
],
[
["🐯", "🎅"],
["🎅", "😈"]
]
]
];

function saveSanta(arr) {
// Your code here
let myFlatArr = arr.flat(Infinity)
let myNewArr = []
console.log(myFlatArr)
for (let i = 0; i < myFlatArr.length; i++) {
if (myFlatArr[i] === "🎅") {
myNewArr.push("🎅")
}
}
return myNewArr
}

// Check the returned results from saveSanta()
console.log(saveSanta(dangerArray))
Console
[
"🎅"
,
"👺"
,
"🎅"
,
"🦁"
,
"👹"
,
"🎅"
,
"🎅"
,
"🐻"
,
"🧌"
,
"🎅"
,
"🐯"
,
"🎅"
,
"🎅"
,
"😈"
]
,
[
"🎅"
,
"🎅"
,
"🎅"
,
"🎅"
,
"🎅"
,
"🎅"
,
"🎅"
]
,
/index.html
LIVE