Let's assume we have an array of items:
const arr1 = [22, 54, 67, 11, ...so on]
and empty one:
let arr2 = []
I can add random item with:
arr2 = [...arr2, arr1[Math.floor(Math.random()*arr1.length)]]
BUT how can I add a random item from first array to 2nd and already added should not be added?
Yes, we can keep added indexes in some tmp variable, but it doesnt seems right and I think there should be a different solution.
NOTE: array spreads because I need to add an item with some events. For example user click to button and new item will be added to 2nd array, and this array may contain already added elems
arr1as you add them toarr2. Use a copy ofarr1is you want to preserve the original