Random Month

Settings
close
Items   Rows

Features of this Random Month Decision Maker

  • Lets you decide between multiple choices of Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec and more
  • Change or add your custom choices
  • Start and Stop the decision maker at your own will

Javascript code for this Random Decision Maker

How to code a random generator that selects a Random Month

Here is the code for a JS Decision Maker that randomly selects from the list of following options: Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec


    // Random Month
        
        // a list containing the options
        var list = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

    
                   
        // define the range of numbers to pick from
        var lowest = 0;             // lowest possible index of the list
        var highest = list.length-1;           // highest possible index of the list
        var number_of_decisions = 1;    // how many decisions to make   

        var this_decision = []; // array to store the results of this decision

        for (var j = 1; j <= number_of_decisions; j++) {

            // loop for the number of decisions

            // for each decision, generate a number between lowest and highest indices of the list
            var decision_number = Math.floor(Math.random() * (highest-lowest+1) + lowest);

            this_decision.push(list[decision_number]); //store this decision in the array
        }
            

        // print all the generated decisions
            
        for (j = 0; j < this_decision.length; j++) {

            // loop through the decision array 

            //print each decision value followed by a comma
            document.write(this_decision[j]);
            document.write(", ");

        }
            
        
    

    /* 

    Sample output 

    

    */
    


...