scrimba
Frontend Career Path
Getting hired
JavaScript Interview Challenges
Challenge - Pumpkin's Prizes
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

AboutCommentsNotes
Challenge - Pumpkin's Prizes
Expand for more info
index.js
run
preview
console

/*
Scrimba mascot Pumpkin has won the grand prize at an international
cat show. Below are Pumpkin's scores from the judges, as well as all the
prizes he's won. In all the excitement of victory,
they've become a jumbled mess of nested arrays. Let's
help Pumpkin by sorting it out.

Write a function to flatten nested arrays of strings or
numbers into a single array. There's a method
for this, but pratice both doing it manually and using the method.

Example input: [1, [4,5], [4,7,6,4], 3, 5]
Example output: [1, 4, 5, 4, 7, 6, 4, 3, 5]
*/

const kittyScores = [
[39, 99, 76], 89, 98, [87, 56, 90],
[96, 95], 40, 78, 50, [63]
];

const kittyPrizes = [
["๐Ÿ’ฐ", "๐ŸŸ", "๐ŸŸ"], "๐Ÿ†", "๐Ÿ’", "๐Ÿ’ต", ["๐Ÿ’ต", "๐Ÿ†"],
["๐ŸŸ","๐Ÿ’", "๐Ÿ’"], "๐Ÿ’ต", "๐Ÿ’ต", ["๐ŸŸ"], "๐ŸŸ"
];

function flatten(arr){

}

console.log(flatten(kittyPrizes));
console.log(flatten(kittyScores));
Console
โ€บ
undefined
,
โ€บ
undefined
,
/index.html
-1:00