Level 27
Your data looks… weird. It’s certainly not valid JSON the way you’ve pasted it here, so it’s hard to know what to do with it. What is (2) [{…}, {…}] supposed to mean? Or [[Prototype]]? And what is Array(0) doing at the end?
IF the actual structure of your data is this:
[
{
"id": 4,
"created_at": "2022-12-13T17:07:50.000000Z",
"updated_at": "2022-12-13T17:07:50.000000Z",
"test_id": 3,
"question": "Which of the following is not a variable option for split testing?"
},
{
"id": 5,
"created_at": "2022-12-13T17:07:50.000000Z",
"updated_at": "2022-12-13T17:07:50.000000Z",
"test_id": 3,
"question": "How many pixels can you have?"
}
]
– then iterating through it should be fairly easy:
for (q in questions) {
console.log(q.question);
}