function findDevice(id) {
for( let i in devices) {
if( devices.hasOwnProperty(i) && devices[i].id === id)
return devices[i];
}
}
function addDevices(p) {
p.devices = [];
for( let i = 0; i < p.devices_ids.length; i++)
p.devices.push( findDevice( p.devices_ids[i]));
return p;
}
var result = people.map(addDevices);