Module 0 A1

Create a button with the Text - "Pick One", when I click the button it will call a function that will randomly pick one member of the Array - and print that person to the screen

by Jenni Meiklejohn

HTML

<br/>

<input type="button" value="Pick One" onclick="pickClassMate();" />

<p id="student"></p>

JavaScript

function pickClassMate() {

  var myClass = new Array("Nyle", "Ryan", "Rachel", "Elliot", "Ronald", "Daniel", "Evan", "Stephen", "Peyton", "David", "Jospeh");

  var randomValue = myClass[Math.floor(Math.random() * myClass.length)];

  document.getElementById("student").innerHTML = randomValue;
}