i have a array and i need to do it randomly show the output by probability below are my code
var shirts = [
["images/fantastic-logo.png","12.65"],
["images/fantastic-word.png","10.00"],
["images/free-product.png","15.50"]
];
var pos = Math.floor((Math.random() * shirts.length) + 0);
$("#image").html($("<img/>").attr("src", shirts[pos][0]));
$(".price").html("$" + shirts[pos][1]);
i have do the basic math.random() to make it random show the image, now i need to make it show with probability, for example probability for showing ["images/fantastic-logo.png","12.65"] was 50%, ["images/fantastic-word.png","10.00"] was 25%, ["images/free-product.png","15.50"] was 25%.
Thanks for everybody help