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.pn
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
/* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */
getRandomInt(3)
If you get 0 or 1, the first image is selected. But this method is not elegant. Please refer to the link below.
Generate A Weighted Random Number