I’m trying to generate 5 random numbers within a range. I’m saving these inside an array through the use of a for loop.
for ( var j:int = 0; j < (questions); j++) {
var randomNum:Number = Math.floor(Math.random()*(1+MAX_number-MIN_number))+MIN_number;
var answerNumbers:Array = new Array();
answerNumbers[j] = (randomNum);
}
The result of this is that the 5th slot has a number. The first 4 are “undefined”. Why would the last loop work and the others fail?