Ok I am building a script that takes a list of teams, selects 1 of them, and puts them into a group. Then it goes back, selects another randomly and puts them in another group.
That works great, except of course I get duplicates. So my thought in checking for duplicates, was to first replace the selected team with a new value ("null"). Then I could just check for the value "null" each pass, and if it was found, redo the selection.
Problem is I am having trouble getting it to replace values and stay that way for every pass. Here is the simple selection code im using...
function getTeamA() {
var whichTeam=get_random();
var team=new Array(7)
team[0]="Elks";
team[1]="Dogs";
team[2]="Cats";
team[3]="Tigers";
team[4]="Bulls";
team[5]="Sharks";
team[6]="Jets";
team[7]="Sheep";
pickA = team[whichTeam];
}
I thought of using splice() or just using something like
newValue = "null"
team[whichTeam] = newValue
But when I do either, it either doesnt work at all, or it displays "null" on the line with the original value, instead of replacing. So I can't even get to the next step of checking for it.
Any Help?
That works great, except of course I get duplicates. So my thought in checking for duplicates, was to first replace the selected team with a new value ("null"). Then I could just check for the value "null" each pass, and if it was found, redo the selection.
Problem is I am having trouble getting it to replace values and stay that way for every pass. Here is the simple selection code im using...
function getTeamA() {
var whichTeam=get_random();
var team=new Array(7)
team[0]="Elks";
team[1]="Dogs";
team[2]="Cats";
team[3]="Tigers";
team[4]="Bulls";
team[5]="Sharks";
team[6]="Jets";
team[7]="Sheep";
pickA = team[whichTeam];
}
I thought of using splice() or just using something like
newValue = "null"
team[whichTeam] = newValue
But when I do either, it either doesnt work at all, or it displays "null" on the line with the original value, instead of replacing. So I can't even get to the next step of checking for it.
Any Help?