Карта location_code работает нормально и выдает правильный результат.
Затем я хочу сопоставить результат, чтобы найти индексы места проведения_code.indexOf(venue_code[n]).
Код: Выделить всё
mainArray = [
{ code: 1, name: 'AC Milan' },
{ code: 2, name: 'Juventus' },
{ code: 3, name: 'AS Roma' },
{ code: 4, name: "Napoli"},
{ code: 9, name: "Inter Milan"}
];
filterArray = [4, 1, 3, 2];
const venue_code = filterArray.map(c => mainArray.findIndex(v => c === v.code));
for(n=0; n
Подробнее здесь: [url]https://stackoverflow.com/questions/79339159/mapping-a-object-and-return-the-index-with-result[/url]
Мобильная версия