Random Number Generator Assistance

I’m a psychologist designing an experiment to test how quickly subjects are able to discriminate between words. Subjects will indicate whether the words displayed are the same or different by pressing S or D which will load the next pair.

I want to have the program randomly present either two words or the same word twice but am having a hard time with the random number generation. I want the formula to return a 1 or 2 and use conditional logic after that. Here’s the random number formula I’ve been stuck on for a while. Any advice?

function pressDifferent (evt:MouseEvent):void
{
{
if(trace.(Math.floor(Math.random()*(1+2-1))+1).toString()))==2)
{
txtRight.text = btText[a];
txtLeft.text = btText[a];
a++;
}
else
{
txtRight.text = btText[a];
a++;
txtLeft.text = btText[a];
a++;
scoreResponse;
}
}

}