In this activity, you will take a list of image IDs listed in picsum-list.js and create a gallery of images using the Lorem Picsum service.
Lorem Picsum is an image service that allows you to embed placeholder photos into your web pages. The images are pulled from open-source Unsplash images.
For example, the following HTML displays this puppy image
<img src="https://picsum.photos/id/237/300/300" alt="Lorem Picsum Image">- Declare an empty string variable named
outputor similar. - Create a
forloop so thatiiterates through each index of the array:- initialized at
i = 0; - increments by one with each iteration;
- stops after
iequalsArray.length - 1.
- initialized at
- Inside the
forloop, use theoutputvariable and the addition assignment operator (+=) (or another method of your choice) create an img list so that:-
each image
srcis based on the image ID in the array:<img src="https://picsum.photos/id/[imageId]/300/300" alt="Lorem Picsum Image">
-
the image dimensions are 300px x 300px.
-
- Finally, after the
forloop finishes, useElement.innerHTMLto assign youroutputstring to page element.