Have you ever wondered why adding curly braces to the filter argument causes it to not work as expected? Let's explore this issue further.
// Dive into your code here:
function justCoolStuff(arr1,arr2){
var newArray = arr1.filter(word => {arr2.includes(word)});
return newArray
}
const coolStuff = ['gameboys', 'skateboards', 'backwards hats', 'fruit-by-the-foot', 'pogs', 'my room', 'temporary tattoos'];
const myStuff = [ 'rules', 'fruit-by-the-foot', 'wedgies', 'sweaters', 'skateboards', 'family-night', 'my room', 'braces', 'the information superhighway'];
console.log(justCoolStuff(myStuff, coolStuff)
It might seem strange that when the curly braces are removed, the code runs smoothly. After all, shouldn't it be correct syntax since we are using a function? Share your thoughts on this!
// Dive into your code here:
function justCoolStuff(arr1,arr2){
var newArray = arr1.filter((word) => arr2.includes(word));
return newArray
}
const coolStuff = ['gameboys', 'skateboards', 'backwards hats', 'fruit-by-the-foot', 'pogs', 'my room', 'temporary tattoos'];
const myStuff = [ 'rules', 'fruit-by-the-foot', 'wedgies', 'sweaters', 'skateboards', 'family-night', 'my room', 'braces', 'the information superhighway'];
console.log(justCoolStuff(myStuff, coolStuff)