Array Mapping

by Ryan Brackett

JavaScript

// What you have
var officers = [
  { id: 20, name: 'Captain Piett' },
  { id: 24, name: 'General Veers' },
  { id: 56, name: 'Admiral Ozzel' },
  { id: 88, name: 'Commander Jerjerrod' }
];
const officersIds = officers.map(officer => officer.id);
console.log(officersIds)