Question: Please explain nested for loops in Javascript like I'm 5 years old. No matter how many examples I look at of nested for loops, I

Please explain nested for loops in Javascript like I'm 5 years old. No matter how many examples I look at of nested for loops, I can't really understand what they're doing, or when I'd actually want to use them. Every time I look at an example of someone using them, I figure I can just call on the items in a single loop. I can't find many concrete examples where I'd say ''ahh, I definitely need to nest for loops for this''. I did this project recently, and I still can't conceptualize what the loop is actually doing:

axios.get("https://lambda-times-backend.herokuapp.com/articles").then(response => {

console.log(response);

const cardsContainer = document.querySelector('.cards-container');

const arrayFromResponse = Object.values(response.data.articles);

arrayFromResponse.forEach((item) => {

item.forEach((article) => {

cardsContainer.appendChild(articleCreator(article));

})

})

}).catch(error => {

console.log("the data was not returned", error)

});

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!