5 Min, 10 Min, 15 Min Or 20 Min

Settings
close
Items   Rows

Features of this 5 min, 10 min, 15 min or 20 min Decision Maker

  • Lets you decide between multiple choices of 5 min, 10 min, 15 min, 20 min 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 choice between 5 min, 10 min, 15 min or 20 min

Here is the code for a JS Decision Maker that randomly selects from the list of following options: 5 min,10 min,15 min,20 min


    // 5 min, 10 min, 15 min or 20 min
        
        // a list containing the options
        var list = ['5 min', '10 min', '15 min', '20 min'];

    
                   
        // 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 

    

    */
    


...