Forum Moderators: open
1) Check if a random number is already located in a string, with "¦" on either side of it
2) If it's not located there, then choose another random number
3) If there is no random number other than the ones listed, then execute the alert function.
I need help with this really badly, so please respond ASAP!
[pre]
Array.prototype.getRandom = function(start, stop)
{
start = start¦¦0; stop = stop¦¦this.length;
return this[ start + Math.floor( Math.random()*(stop-start) ) ];
}numbers = "14¦45¦78";
rand = numbers.split('¦').getRandom()
[/pre]
Obviously, more devious versions of the above could also be applied if there were more than one numeric value, but each was in a fixed relation to the pipe symbols and other string content.
You might wish to investigate parseInt() and parseFloat() in conjunction with isNaN() if you wish to test strings for numeric value or quality contained therein.
I'll leave the randomness to Bernard.