const data = [1, 2, 3, 4, 5];
const result = data.reduce((acc, val) => acc.concat(Array.from({ length: val }, (_, index) => val + index)), []);
console.log(result);
Ответ: [1, 2, 3, 3, 4, 5, 4, 5, 6, 7, 5, 6, 7, 8, 9]
JavaScript test | #JavaScript & Max