pickMyArray

by chris richarde

HTML

<input type="button" id="blue" value="pick one" onClick="pickMyArray();" />
<br/>
<div id="output">
  Hello Dr Eaglin! Please press the button to select student for automatic A for this class.
</div>

JavaScript

//can't seem to get this to work. Up top in the DOM the buttton is set and onclick is calling the function. 

 // myArray is set globally
 var myArray = ["Kristopher", "Ignacio", "Vanessa", "Charlene", "Casey", "Christian", "Adnane",
   "Nicholas", "Ronald", "Andrew"
 ];

 function pickMyArray () {
   //random is set by built in function to randomly pick from myArray given its array length.
   var random = myArray[Math.floor(Math.random() * myArray.length)];

   //this gets the random variable and assigns it to output
  document.getElementById("output").innerHTML = random;

   //then it should be able to be read in div id as I understand it. I also couldn't get your JS fiddle for the first assignment to work. Are there extensions I need to apply?

 }