I may be overlooking something obvious but this just doesn't seem to go right.
I have this little code block in which an addEventListener method should trigger a function and meanwhile pass a parameter through so I can work with different functions while creating all EventListeners with one loop.
It does work, but the function gets invoked immediately when the site finishes loading.
Why doesn't the function wait until it gets triggered, but runs immediately?
var html = document.getElementsByTagName('html');
var pics = document.getElementsByClassName('pics');
var functions = [];
for(h=0;h<pics.length;h++){
    array[h] = show(h);
}
for(p=0;p<pics.length;p++){
    pics[p].addEventListener('click',array[p]);
}
function show(index){
    html[0].style.backgroundColor = "black";
}
 
     
    