It's not that hard to make that! I'll explain it to you using a simple code:
CODE
var numarray = new Array(1, 1, 1, 2, 2, 2, 3, 4);
/* This is the array of possible values. The more times you use a number, the more times it will return. */
var rand = Math.round(Math.random()*(numarray.length-1));
/* This code creates a random number between 0 and (numarray.length-1). */
var num = numarray[rand];
/* This piece will take a value out of the array, based on the random number of the second line of code. */
And this will always return one of the values you want! Of course, you speak of a function that returns a value, so it will be more like this:
CODE
function randomNumber(){
var numarray = new Array(1, 1, 1, 2, 2, 2, 3, 4);
var rand = Math.round(Math.random()*(numarray.length-1));
var num = numarray[rand];
return num;
}
Reply