I am trying to select a random element from an array and display it using jQuery. So far I can only click through the array and reset back to 0. Not sure how to use the Math.random(); exactly here.
Codepen: http://codepen.io/Travo100/pen/xAKji
counter = 0;
var compArray = [ "Cat", "Dog", "Rabbit", "Cow", "Sheep", "Human" ];
$('a').click(function () {
counter = (counter + 1) % compArray.length;
$(this).html(compArray[counter]);
});