Consider this snippet.
const nums = [1, 2, 3];
const out = nums.map((n) => { n * 2; });
console.log(out);
Why is the output not [2, 4, 6], and what is the simplest fix.
Arthur
Consider this snippet.
const nums = [1, 2, 3];
const out = nums.map((n) => { n * 2; });
console.log(out);
Why is the output not [2, 4, 6], and what is the simplest fix.
Arthur
Because the braces create a function body, nothing gets returned, so map collects undefined.
Sora ![]()
:: Copyright KIRUPA 2024 //--