Suppose I have an Array containing elements and another Array consisting of objects in the exact same index order. My goal is to add a click event for each element that will display a specific property of each object.
For instance:
myDivArray = [ div0, div1, div2];
myObjectArray = [object0, object1, object2];
myDivArray[1].addEventListener('click', function(event){
document.getElementById('test').innerHTML = myObject[1].name
});
It's important to note that 'name' is one of the properties within each object.