I'm trying to clean this func (Y) and discovered something I don't understand. The idea is to return a certain number of {objects} from the func.
let y = watchList
.map(function (item) {
return { title: item["Title"] }
});
//[{…}, {…}, {…}, {…}, {…}]
let x = watchList
.map(item => {
title: item["Title"]
}
);
//[undefined, undefined, undefined, undefined, undefined]
Y lets me create an Object inside the func, but with the arrow functions on X I'm not able to do so.
Why is this happening?
Thank you.