Hi,
I have been doing a course JavaScript syntax part II and at a code challenges: intermediate JavaScript: justCoolStuff()
I can’t understand how this code works:
function justCoolStuff(firstArray) {
function isInSecondArray(item) {
return item
}
return firstArray.map(isInSecondArray);
}
const coolStuff = [
"gameboys",
"skateboards"
];
console.log(justCoolStuff(coolStuff)); // print [ 'gameboys', 'skateboards' ]
Me question is why does a return item
print [ 'gameboys', 'skateboards' ]
?
I didn’t specifiy item
I only specify isInSecondArray
without parenthesis. If I return item
or return isInSecondArray
the results are the same.