const arr1 = [[101,'Корова'], [102,'Осел'], [103,'Индюк'],...
const arr2 = [[1001,'Домашнее животное'], [1002,'Дикое животное'],...
const arr3 = [
[101, 1001, "text", 7777],
[102, 1001, "text", 6666],
[103, 1001, "text", 5555],
[104, 1001, "text", 4444],
[105, 1002, "text", 3333],
[106, 1002, "text", 2222],
...
[999, 9999, "text", 1111]];
const obj = [
{
"id": 1,
"title": "Домашнее животное",
"animal": "Корова",
"array": ["text", 7777]
},
{
"id": 2,
"title": "Домашнее животное",
"animal": "Осел",
"array": ["text", 6666]
}
]
const obj = arr3.reduce((acc, cur, i) => {
return acc;
}, {});
function toObject(animals, titles, list) {
animals = Object.fromEntries(animals);
titles = Object.fromEntries(titles);
return list.map(([animal, title, ...array], i) => ({
id: i + 1,
title: titles[title],
animal: animals[animal],
array
}));
}
toObject(arr1, arr2, arr3);