Get Programming with JavaScript - Listing 7.13

Listing 7.13 - Shorthand properties and argument destructuring

const buildPlanet = function (name, position, type, radius, rank) { return { name, position, type, radius, sizeRank: rank }; }; const getPlanetInfo = ({name, position}) => `${name.toUpperCase()}: planet ${position}`; const planet1 = buildPlanet("Jupiter", 5, "Gas Giant", 69911, 1); const planet2 = buildPlanet("Neptune", 8, "Ice Giant", 24622, 4); console.log(getPlanetInfo(planet1)); console.log(getPlanetInfo(planet2));