JS map return object
Use .map without return in simple way. Also start using let and const instead of var because let and const is more recommended
const rockets = [
{ country:'Russia', launches:32 },
{ country:'US', launches:23 },
{ country:'China', launches:16 },
{ country:'Europe(ESA)', launches:7 },
{ country:'India', launches:4 },
{ country:'Japan', launches:3 }
];
const launchOptimistic = rockets.map(elem => (
{
country: elem.country,
launches: elem.launches+10
}
));
console.log(launchOptimistic);
You're very close already, you just need to return the new object that you want. In this case, the same one except with the launches value incremented by 10:
var rockets = [
{ country:'Russia', launches:32 },
{ country:'US', launches:23 },
{ country:'China', launches:16 },
{ country:'Europe(ESA)', launches:7 },
{ country:'India', launches:4 },
{ country:'Japan', launches:3 }
];
var launchOptimistic = rockets.map(function(elem) {
return {
country: elem.country,
launches: elem.launches+10,
}
});
console.log(launchOptimistic);