const array = ["a", "b", "c", "d", "e", "f", "g"]; while (array.length) { const ndx = Math.random() * array.length | 0; const elem = array.splice(ndx, 1)[0]; console.log(elem); } Run code snippet