Front End Development Libraries Projects - Build a Random Quote Machine

I have rebooted my attempt to solve this. I am now trying to work in the JS window rather than the HTML window. I believe this means I am working with JSX/REACT. It does not want to receive instructions to do a for loop. I am getting an error following this chunk of code:

for (let i = 0; i < database.length; i++) {
  quoteDatabase[i] = [database[i].quote, database[i].author];
}

The error says: “Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.”

My full code is at https://codepen.io/tony_the_tiger-the-typescripter/pen/jOxrOBW?editors=1111

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Front End Development Libraries Projects - Build a Random Quote Machine

Link to the challenge:

I uncommented all stuff in your pen which was commented out.

And the error I am getting is this:

Uncaught ReferenceError: database is not defined 
 at https://cdpn.io/cpe/boomboom/pen.js?key=pen.js-8c77f6a5-9b8b-fc39-5d02-00ae69a5e995:482

What does that error mean? I have successfully console.logged database.

Also, I thought I could insert JS in JSX/REACT? Do I have to map with keys to do a for loop where it is now?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.