I’m trying to figure out how to determine if the 2nd array contains the same number of items, and all correct, as the first array:
//For my purposes, if the user selects answer "B" they get an incorrect response
//but if they don't select "A", "C" and "D" together, they also get an incorrect response
// Need to know which item of arrayA is missing from arrayB
Array.prototype.filter = function(arr) {
var incorrect:String = "B";
var mismatchArray:Array = [];
var tempArray = arr.concat();
if (arrayA == tempArray) {
//trace(tempArray); // not working
}
for (var i:Number = 0; i < arr.length; i++) {
var exists:Boolean = false;
for (var ii = 0; ii < this.length; ii++) {
if (arr* == this[ii]) {
trace(arr* + " choice is correct");
exists = true;
break;
}
if (arrayA.length == arr.length) {
trace("Same number of answers");
// Need to know if they are also all correct choices
}
}
if (exists == false) {
mismatchArray.push(arr*);
trace(mismatchArray + " is the item not in arrayA");
}
}
return mismatchArray;
};
var arrayA = ["A", "C", "D"];
var arrayB = ["B", "C"];
var difference:String = arrayA.filter(arrayB);
//trace(difference);