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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started