Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

dev7
Guest
//Random Array Open Source by Devin

/*
Targets = the Array
mathRandoms = math function "randomizing" the array
*/

var Targets = new Array();
Targets[0] = "Uno";
Targets[1] = "Dos";
Targets[2] = "Tres";

var mathRandoms = Math.floor(Math.random()*Targets.length);

document.write(Targets[mathRandoms]);


Wasn't in here, and it can be pretty useful even if it is simple. Should be easy enough to understand.


Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Maybe prototype it or make it into a reg. function? That way it can be reused in the same script.

Array.prototype.rRand = function() {
return this[Math.floor(Math.random() * this.length)];
}



Last Edit: Mar 10, 2007 2:10:13 GMT by Aaron

dev7
Guest
I'm not too familiar with prototypes actually. I'll learn eventually, but right now I am studying moderate form manipulation.

newBookmarkLockedFalling