![random pictures random pictures](http://www.dumpaday.com/wp-content/uploads/2017/03/random-pictures-24-2.jpg)
Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site. This says that the source of the image myPicture is set based on the array myPix, and the value at this moment is dependent on the value of randomNum.
![random pictures random pictures](http://www.dumpaday.com/wp-content/uploads/2017/02/random-pictures-20-2.jpg)
Here we build an array of three images, and stuff it into the variable myPix. var myPix = new Array("images/lion.jpg", "images/tiger.jpg", "images/bear.jpg").Var randomNum = Math.floor(Math.random() * myPix.length) document.getElementById("myPicture").src = myPix Var myPix = new Array("images/lion.jpg","images/tiger.jpg","images/bear.jpg") Listing 4.21 You can display random images on your page with this script, which uses JavaScript’s Math.random method to generate a random number. Listing 4.20 This simple HTML creates the page for a random image. Depending on the value of the random number generated by the script, the user is presented with the lion, the tiger, or the bear.