Does the Object literal notation not work inside map function? I tried this in Node 12 and 15 REPL
> nums = [1,2,3,4]
[ 1, 2, 3, 4 ]
> nums.map(n => { n })
[ undefined, undefined, undefined, undefined ]
> nums.map(n => new Object({n}))
[ { n: 1 }, { n: 2 }, { n: 3 }, { n: 4 } ]
Try this:
nums.map(n => ({ n }))
Without the parentheses, { n } is being interpreted as the body of your function. By including parentheses, you're indicating that { n } should be implicitly returned instead.
Here is an overview of implicit vs. explicit returns, which should help provide some more detail.