I am trying to generate a random result from array using JavaScript. My goal is, when the user clicks the button, I want to grab a random result from array named 'favorites'. It only works once the page is refreshed, but when you click it at the second time, it returns the same result.
$('#button').click(function(){
var favorites = ["http://google.com", "http://yahoo.com", "http://msn.com", "http://apple.com"];
var favorite = favorites[Math.floor(Math.random() * favorites.length)];
var postmessage = "hi my favorite site is " + favorite;
alert(postmessage);
});