Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
I am trying to skip first 2 entries and tha frist 4 and than first 6 like this... up too so on, currently i am using for of loop

I am working with JSON data with for-of loop how can I do and one more point what if the last entry is single like


my js code:
var counter=0,temp=2;
function load() {
  fetch("https://jsonplaceholder.typicode.com/photos")
    .then(function (response) {
      return response.json();
    })
    .then((response) => {
    for (var [index,value] of response.entries()) {
      alert(value);
        if(index < temp){
          var wrapper = document.createElement("div");
          var img = document.createElement("img");
          var title = document.createElement("h6");
          img.src = value.url;
          title.innerHTML = value.title;
          wrapper.setAttribute("class", "wrapper");
          img.setAttribute("class", "img-class");
          title.setAttribute("class", "title");
          wrapper.appendChild(img);
          wrapper.appendChild(title);       document.getElementById("main").appendChild(wrapper);
          index++;
        }else{
          index = index;
          counter = counter + 2;
          temp=counter;
          break;
        }
      }
    });
}
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda