I want to merge 3 sets and then itereate over their union, but I'd like this union to be randomized.
If I do:
const a = new Set([1,2,3]);
const b = new Set([10,20,30]);
const c = new Set([100,200,300]);
const d = new Set([...a, ...b, ...c]);
const iterator = d.values();
for (let i = 0; i < 9; i++) {
console.log(iterator.next());
}
I obviously get them in order, instead of having them shuffled. Is there another (more idiomatic and/or effifcient) way than using a shuffling array function as from this question like this:
let setArray = Array.from(d);
shuffleArray(setArray);
const randomSet = new Set(setArray);