let initToIndex = arr1.reduce((acc, item, idx) => {
acc[item[0].init] = idx;
return acc;
}, {});
arr2.flat().forEach(x => {
let idx = initToIndex[x.init];
if (!initToIndex.hasOwnProperty(x.init)) {
idx = arr1.push([]) - 1;
initToIndex[x.init] = idx;
};
arr1[idx].push(x);
});
найти объект
найти самое большое значение
const obj = arr.flat().reduce((max, n) => max?.age > n.age ? max : n, null);
const val = Math.max(...arr.flat().map(n => n.age));
new Date(1622022110 * 1000)