Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AhmedHelalAhmed/8a3516a3de27f1554b54f436b3476138 to your computer and use it in GitHub Desktop.

Select an option

Save AhmedHelalAhmed/8a3516a3de27f1554b54f436b3476138 to your computer and use it in GitHub Desktop.
script to get certain value from array of objects
const inputs=[
{
macAddress: 'A',
flag: false,
},
{
macAddress: 'B',
flag: false,
},
{
macAddress: 'C',
flag: true,
},
];
let output=[];
inputs.forEach(function(input) {
console.log(input);
var key = input.macAddress;
var value = input.flag;
output[key]=value;
});
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment