I’m confused and hoping someone can point me in the right directions.
I have a class myClass with a getRandomLetter function that returns a String.
It uses _model.lettersArray[rp.getNum()]; to get a random letter from an array. the function checks if this new letter is the same value as an unchanging value corLetter. if this value is the same i want a new random letter to be generated and returned. But then i need to check that new letter. but i can’t think of how to do it without causing a recursive loop. Please see code below
l
etter1:String = myClass.getRandomLetter();
public function getRandomLetter(): String
{
newLetter = _model.lettersArray[rp.getNum()];
var corLetter:String = _model._correctLetter.toLowerCase();
if(newLetter.toLowerCase() == corLetter)
{
newLetter = _model.lettersArray[rp.getNum()];
}
return newLetter;
}
thanks in advance for any help