Question

Please explain nested for loops in Javascript like I'm 5 years old. No matter how many...

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)

    

});  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

EXPLANATION:

EXAMPLE:

OUTPUT:

Please upvote if you like my answer and comment below if you have any queries.

Add a comment
Know the answer?
Add Answer to:
Please explain nested for loops in Javascript like I'm 5 years old. No matter how many...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment 5 will be way different. It will be more like what you will receive in...

    Assignment 5 will be way different. It will be more like what you will receive in a programming shop. By that I mean that some things are built for you and others you will need to create or finish. P.S. part of your grade will include: Did you add in the required files? Did you rename your project? does your linear searches work? Did you put your code in the correct modules? did you change modules that you weren't supposed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT