Here is the code for a JS Decision Maker that randomly selects from the list of following options: I,II,III,IV,V,VI,VII,VIII,IX,X
// I, II, III, IV, V, VI, VII, VIII, IX or X
// a list containing the options
var list = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'];
// 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
*/