Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!