Assigning array element to variable

So I have an array of some names:

var firstNames = new Array ();

firstNames = ["Brian","Paul","George","Jacob","Richard"];

I want to assign a random name from this array to some variables:

var person1 = "";
var person2 = "";
var person3 = "";

var firstNames = new Array ();
    
firstNames = ["Brian","Paul","George","Jacob","Richard"];

From what I’ve found looking for an answer to this already, this is supposed to work:

var person1 = randomFName;
var person2 = randomFName;
var person3 = randomFName;
    
var firstNames = new Array ();
var randomFName = "";

function Start () {

randomFirstName();

}

function randomFirstName() {
        
firstNames = ["Brian","Paul","George","Jacob","Richard"];

randomFName = firstNames[Random.Range(0,firstNames.Length)];

}

Now this gives me a few errors and I know that I’m probably way off and this should be simple. I just want to be able to assign one of the names from to array to a variable but I want it to be a random name every time. To be clear, I don’t want “randomFName” to be set as a name from the array and then every “person” variable to be set as that name, but for a random name to be selected for everyone. I realize it’s still possible for each variable to be set as the same name anyways.

You should probably post the specific errors or exceptions that are being thrown, that might be a little more helpful.
However, if I understand correctly what you are trying to do, I’d probably implement it like this:

var person1;
var person2;
var person3;
 
var firstNames = new Array ();
 
function Start () {
    firstNames = ["Brian","Paul","George","Jacob","Richard"];
    person1 = getRandomFirstName();
    person2 = getRandomFirstName();
    person2 = getRandomFirstName();
}
 
function getRandomFirstName() {
    return firstNames[Random.Range(0,firstNames.Length)];
}

If you’re getting an off-by-one issue (possibly IndexOutOfRangeException), you might have to use Random.Range(0,firstNames.Length-1), as the Length property returns the number of items in the array, which is equal to the index of the last item plus one.