What does this log when the forEach and map callbacks return early?
const result = [1, 2, 3, 4].forEach((n) => {
if (n === 2) return;
console.log(n);
return n * 10;
});
console.log(result);
const mapped = [1, 2, 3].map((n) => {
if (n === 2) return;
return n * 10;
});
console.log(mapped);
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…