I wanted to do a very basic mapping to JS Object from some array of integers;
[1,2,3,4,5].map(val => {num: val})
.forEach(result => console.log(result));
But as you can see it returns all undefined, is it due to the usage of curly brackets that is confused with lambda's body part? Using a boring syntax works though;
[1,2,3,4,5].map(function(val) {return {num: val}})
.forEach(result => console.log(result));
Also this;
[1,2,3,4,5].map(val => {return {num: val}})
.forEach(result => console.log(result));
Is there no way to achieve what I am trying to do with lambda notation? Since the sleeker the better IMO