The principle is the same as what you do with the status text.
You create an array of different texts. Then you need to get a random number which would be the number of the element to take from that array.
Random numbers can be generated like this:
code:
var myRandomNumber = Math.floor((upperbound - lowerbound + 1) * Math.random() + lowerbound);
where
upperbound is the biggest number and
lowerbound the lowest number in the range you which to choose from.
Thus if you whish to choose a random number from 5 to 10, you do:
code:
var myRandomNumber = Math.floor((10 - 5 + 1) * Math.random() + 5);
which equals:
code:
var myRandomNumber = Math.floor(6 * Math.random() + 5);
For the array of random texts, it is important to know that arrays start with index 0 (thus this would be our lowerbound). The length of the array determines our upperbound:
code:
var myTextArray = new Array("Hello", "Bonjour", "Yo", "Hi");
var lowerbound = 0;
var upperbound = myTextArray.length-1;
var myRandomNumber = Math.floor((upperbound - lowerbound + 1) * Math.random() + lowerbound);
var myRandomText = myTextArray[myRandomNumber];
optimized, this would be:
code:
var myTextArray = new Array("Hello", "Bonjour", "Yo", "Hi");
var myRandomText = myTextArray[Math.floor(myTextArray.length * Math.random())];