Skip to content
Advertisement

For Loops and React JS

So I have this function here:

JavaScript

and its suppose to insert list items into and unorder list from an array of card objects.

JavaScript

If I do a console.log on arr I can verify that it is an array of cards, but if I console.log card from inside the for each it does not even trigger. It’s like the for each does not run. Does anyone have an idea why this is happening?

Advertisement

Answer

Thanks for all the advice. In hindsight, I should have stuck to what I was learning and not try to freestyle. React is about using states. So rather than having a function that will generate HTML from an array of data and I had to do use “the state”. Then code the render to loop through the list of cards when the button is pressed.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement