In this project, images are pulled from the Lorem Picsum API when a button is clicked.
-
Create a function that randomly chooses one of the objects in the images array:
- Use Math.random() and multiply it by the length of the array.
- Use Math.floor() to round the number down to a whole number, aligning with one of the index positions.
-
Create a function to update the photographer’s name and the image URL for the randomly selected image.
-
Program the “Show me an image!” button with a click event to reveal the image and photographer’s name.
View the Image Generator here: https://ivgeek.github.io/image-generator/
JavaScript Fundamentals