// I've tried to do something like this but I haven't had any success. I'm not sure if this is the correct syntax
<p id = "Person"></p> var x = <img src="bob.jpg" width = "500" height = "500"> var y = <img src="joe.jpg" width = "500" height = "500"> var z = <img src="chad.jpg" width = "500" height = "500"> Try to pick out random image from array
var myArray = [ x, y, z ]; var randomNumber = myArray[Math.floor(Math.random()*myArray.length)]; Then how do I display it? Is there another document. that i'm supposed to use?
document.getElementById("Person").innerHTML = randomNumber https://stackoverflow.com/questions/67260690/how-to-get-a-random-element-of-array-of-images-and-display-it April 26, 2021 at 12:02PM
没有评论:
发表评论