So I'm trying to print a lot of images automatically via a For Loop. I have three lists with images of a certain type respectively: forest, people and ocean. I want to run through and print every picture in every category. I've tried for hours but I am a complete beginner so I might have missed something silly. This is my code so far:
<script>
const forrest = ["https://cdn.pixabay.com/photo/2020/03/20/13/23/mountain-4950653_1280.jpg", "https://cdn.pixabay.com/photo/2020/01/07/14/18/forrest-4747692_1280.jpg", "https://cdn.pixabay.com/photo/2018/07/30/11/30/landscape-3572374_1280.jpg"]
const people = ["https://cdn.pixabay.com/photo/2014/09/07/21/52/city-438393_1280.jpg", "https://cdn.pixabay.com/photo/2015/05/15/14/50/concert-768722_1280.jpg", "https://cdn.pixabay.com/photo/2017/08/06/12/06/people-2591874__480.jpg"]
const ocean = ["https://cdn.pixabay.com/photo/2016/11/29/04/19/ocean-1867285_1280.jpg", "https://cdn.pixabay.com/photo/2018/06/13/18/20/wave-3473335__340.jpg", "https://cdn.pixabay.com/photo/2016/12/17/14/33/wave-1913559__340.jpg"]
const type = [forrest, people, ocean]
function myFunction() {
for (var i = 0; i < type.length; i++); {
var list = type[i];
for (var pictures = 0; pictures <= list.length; pictures++); {
var img = document.createElement("img");
img.src = list[pictures];
document.body.appendChild(img);
}
}
}
</script>
I've inserted some example photos in the code above. My photos are also from the web. The code prints the first photo in the first list but not any other photo.