Results 1 to 2 of 2
  1. #1
    Super Sh!t Stirrer SSanf's Avatar
    Join Date
    January 18th, 2005
    Posts
    9,944
    Question Help with Javascript?
    I am trying to generate random text output from 54 arrays of variables.

    Does anyone know how I would modify this function which outputs three variables from three arrays so it will out put 54 variables?

    function profundity() {
    subscript=rndnumber(w1max)
    msg = " " + w1[subscript]
    subscript=rndnumber(w2max)
    msg = msg + " " + w2[subscript] + " "
    subscript=rndnumber(w3max)
    msg = msg + w3[subscript] + " "
    return msg

    The arrays are named w1 through w54.
    Comments are opinion unless otherwise noted. Remember, pillage first. Then burn. Half of all people in the world have IQs under 100. You best learn to trust ol' SSanf!

  2. #2
    Newbie
    Join Date
    January 18th, 2005
    Location
    SF Bay Area
    Posts
    4
    I would do this as a two dimensional array. Something like...

    var w = new Array(54);
    for (i=0;i<w.length;i++){
    w[i]=new Array();
    //populate your array here. i.e. w[i][0]='a';w[i][1]='b'; etc...
    }

    function profundity(){
    var msg = new String("");
    for (i=0;i<w.length;i++){
    subscript = rndnumber(w[i].length-1); // this is assuming that rndnumber returns 0-max inclusive. If not, then just remember that arrays start at 0 and go to length-1
    msg+=" "+w[i][subscript];
    }
    return msg;
    }

  3. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Can javascript be seen?
    By tbrown in forum Blocking Tips/Advice/scripts
    Replies: 0
    Last Post: August 5th, 2004, 11:33 AM
  2. JavaScript Help
    By FunPortal in forum Programming / Datafeeds / Tools
    Replies: 6
    Last Post: August 9th, 2003, 02:14 PM
  3. javascript help
    By SpaceBandit in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: December 30th, 2001, 08:56 PM
  4. Javascript or otherwise...
    By TH Media in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: December 1st, 2001, 11:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •