let row_data_1 = [["categ_1", 20], ["categ_2", 30]]; let row_data_2 = [["categ_2", 40], ["categ_3", 50]]; let row_data_N = [["categ_1", 60], ["categ_4", 70]]; let arr_row_data = [...row_data_1,...row_data_2,...row_data_N]; let row_data_full=[]; for (const [cat, num] of arr_row_data){ let index = row_data_full.findIndex(([e]) => e === cat); index !== -1 ? row_data_full[index].push(num) : row_data_full.push([cat, num]); } console.log(row_data_full);
Обсуждают сегодня