const arr = [1, 255, 639, 9, 7, 8, 5, 4, 2];
const task = (arr) => {
const len = arr.length;
let index = Math.round(Math.random() * (len -1));
const result = [];
const getNewItem = () => {
let curr = arr[index];
let prev = arr[index];
while (prev === curr) {
index = Math.round(Math.random() * (len -1));
curr = arr[index]
}
prev = curr;
return curr;
}
for (let i = 0; i < 50; i++) {
result.push(getNewItem());
}
return result;
}
спасибо за ваш комментарий, мне очень приятно!