Array Example

Assignment 1

by Jake Jernigan

HTML

<p id =message> This button will select a student randomly from a list
<br><br>


<input type='button' id='myButton' value='Pick One' onClick="chooseStudent()" />

</p>
<div id="output">
</div>

<!--

<div id="output2">
</div>

-->

JavaScript

var students = 
[
  "Andrew", "Casey", "Charlene", "Charlotte", "Che",
  "Christian", "Christoph", "Clayton", "Daniel", "David"
];

function chooseStudent() {
  var random = Math.floor(Math.random() * 10)

  document.getElementById("output").innerHTML =
    students[random];

  // This portion was for testing the output of the random variable 
  // document.getElementById("output2").innerHTML = random;
}