I want to randomly iterate an array runs
while randomly selecting a mainSamplers
and a secondarySamplers
. The below code works but will repeat runs
and I need to keep running it over and over.
// program to get a random samplestrong text
function getRandomItem(arr) {
// get random index value
const randomIndex = Math.floor(Math.random() * arr.length);
// get random item
const item = arr[randomIndex];
return item;
}
let runs = ["W1", "W2/W3", "W4/W6", "W5", "W7/W8", "E1/E2", "E3/E4", "E5/RB", "SA/SB", "LT",
"LR1", "LR2", "LR3", "LR4", "LR5", "LR6", "LR7", "LR8", "Mullet Creek"];
let mainSamplers = ["RAB", "CJ", "AMR", "ND", "RB", "ED", "SD", "MEF"];
let secondarySamplers = ["KD", "SA", "AF", "JT", "EV"];
//1st sample set
const result1 = getRandomItem(runs) + " " + getRandomItem(mainSamplers) + " " +
getRandomItem(secondarySamplers);
console.log("Run" + " " + "Samplers");
console.log(result1);
// need to run this as many times as there are runs and not repeat the runs