This is a great way to learn about objects, and about arrays of objects, but from the questions you are asking it seems your understanding of some earlier steps in the javascript language are in question.
Your loop is looking better, which is great (yes, you needed both an ending condition and one that won’t error). But have you learned how to read the properties of an object? For example:
const questionObj = {
question: "What is 10/2?",
answers: {
a: '3',
b: '5',
c: '115'
},
correctAnswer: 'b'
};
This is not an array of objects, it is just one object. Can you tell me how you would access just that one object’s question? Answer? How would you display the correct answer value? (That third is a curve ball, and extra credit).
When you can comfortably address that, then doing the same thing for an array of those same objects becomes a little less challenging - rather than using questionObj
, you might use questions[i]
, but everything else would be just the same.
As to the helpfulness of this community, if you take the time to read through the forums, you might notice that there are quite a few of us who devote quite a lot of time to doing just this - helping out, guiding learners, and taking the time to do so in a way that fosters learning and challenges the learner. We are always willing to help, around the other things we have going on, because of course we all have lives outside of this.
But… Nobody in this forum is going to hand you a guitar (assuming you’ve never played a guitar), and show you how to jam out like Santana. Nobody in this forum has a magic mouse that is going to show you how to code with arrays of objects and have you simply get it, without taking the time to learn the basics. It takes time, and dedication, and commitment. Both on your part to research and learn, and our part to suggest smaller building blocks first.
You may not like the response you got, and for that I’m deeply sorry, but the fact is, you were given help. It may not have felt like help, but from the outside, it was a clear direction for you to consider.