I have tried creating 4 variables with arrays with random values where there are no two variables with the same value at the same place in the array. For example, if the 27:th value in one variable is 3, then none of the other variables must have 3 as the 27:th value.
I thought the part marked blue would do it (I have also tried it with the “while” exchanged for an “if”), but it doesn`t help.
var totalQuestions = 50;
var correctAnswers = new Array();
var wrongAnswers1 = new Array();
var wrongAnswers2 = new Array();
var wrongAnswers3 = new Array();
for (var i = 1; i<=totalQuestions; i++) {
correctAnswers.push("a"+i);
wrongAnswers1.push("a"+i);
wrongAnswers2.push("a"+i);
wrongAnswers3.push("a"+i);
}
correctAnswers.sort(shuffle);
wrongAnswers1.sort(shuffle);
wrongAnswers2.sort(shuffle);
wrongAnswers3.sort(shuffle);
for (var i = 1; i<=(totalQuestions-20); i++) {
correctAnswers.pop();
}
[color=blue]for (var i = 1; i<=correctAnswers.length; i++) {
while (correctAnswers* == wrongAnswers1* or correctAnswers* == wrongAnswers2* or correctAnswers* == wrongAnswers3* or wrongAnswers1* == wrongAnswers2* or wrongAnswers1* == wrongAnswers3* or wrongAnswers2* == wrongAnswers3*) {
wrongAnswers1.sort(shuffle);
wrongAnswers2.sort(shuffle);
wrongAnswers3.sort(shuffle);
}
}[/color]for (var i = 1; i<=(totalQuestions-20); i++) {
wrongAnswers1.pop();
wrongAnswers2.pop();
wrongAnswers3.pop();
}
trace("correctAnswers: "+correctAnswers);
trace("wrongAnswers1: "+wrongAnswers1);
trace("wrongAnswers2: "+wrongAnswers2);
trace("wrongAnswers3: "+wrongAnswers3);
I would really appreciate help with this.