ЛХ
for (... of $(...)) нельзя использовать, потому что $(...) это не iterable
Size: a a a
ЛХ
AA
AA
ГЩ
DD
DD
ЛХ
В
ЛХ
В
AP
const arr = [1,2,3,4,5,6,7];
function* getRandom(origin) {
const getRandomNumber = max => Math.floor(Math.random() * max);
const copy = [...origin];
while (copy.length) {
const length = copy.length;
const index = getRandomNumber(length);
const item = copy[index];
const last = copy.pop();
if (index !== length - 1) {
copy[index] = last;
}
yield item;
}
return null;
}
const iterator = getRandom(arr);
for (const randomItem of iterator) {
console.log(randomItem);
}
DD
П
AP
П
D
DD
VL
CM