Закрыть Вторая программа: «Сеньор Помидор»

var pictures = [
  'gallery-tomato/tomato-red-large.jpg',
  'gallery-tomato/tomato-yellow-large.jpg',
  'gallery-tomato/tomato-strange-large.jpg'
];

const picturePreview = document.querySelectorAll('.gallery__picture-preview');
const fullPicture = document.querySelector('.full-picture');

// Вариант №1
picturePreview.forEach((element, index) => {
  element.addEventListener('click', () => {
    fullPicture.src = pictures[index];
  });
});

// Вариант №2
const addEventGallery = (preview, photo) => {
  preview.addEventListener('click', () => {
    fullPicture.src = photo;
  })
};

for (let i = 0; i < pictures.length; i++) {
  addEventGallery(picturePreview[i], pictures[i]);  
}