H
H
heisenberg12021-06-26 15:19:03
JavaScript
heisenberg1, 2021-06-26 15:19:03

Why does the function not find (does not see) the object?

What am I doing wrong, why doesn't the function find (see) the object?
The data is transferred from the module to the current js file in order to insert the necessary data (links) into the template with pictures.

Template code (index.html):

<div class="popup__pictures">
        <img src="" class="popup__picture" width="45" height="40" alt="Картинка жилья">
      </div>


Current js file code:
import {createAdverts} from './util.js';
const advertElement = template.cloneNode(true);
const similarAdverts  = createAdverts(1);
const popupPictures = advertElement.querySelector('.popup__pictures');
const imgPopupPictures = advertElement.querySelector('.popup__picture');
popupPictures.textContent = '';

const getPicture = (advert) => {
  for (let ind = 0, img; ind <= offer.pictures.length -1; ind++) {
    img = imgPopupPictures.cloneNode();
    img.src = offer.picture[ind];
    popupPictures.appendChild(img);
  }
};


similarAdverts returns an array with objects: {avatarka: {…}, advert: {…}}.
The advert object contains a picture object.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question