Oakendin
12-31-2003, 04:02 AM
I have a question about the below code. In regards to the variable set as randomNumber. It can return either a 0 or 1. Why would it return a 1 or a 0? I must not have a good understanding of Math.random than. Does a random only work with an array larger than 1. The array use to be larger than 1, but modifications were made that it became one. When it became one, the random returns both 0 and 1 which is what I don't understand.
<%
testText = new Array();
testText[0] = "http://www.codingforums.com/images/icons/icon5.gif";
var randomNumber = Math.floor(Math.random()*testText.length);
%>
<%=testText[randomNumber]%>
Thanks in advance.
<%
testText = new Array();
testText[0] = "http://www.codingforums.com/images/icons/icon5.gif";
var randomNumber = Math.floor(Math.random()*testText.length);
%>
<%=testText[randomNumber]%>
Thanks in advance.