Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
James Hallett
6,605 PointsUsing arrays of objects
I made a quiz using this method. It works great. I was trying to find a way to assign each question separate point values for a correct answer instead of just using a counter. I can't figure how to make that work. Can anyone help?
2 Answers
Antti Lylander
9,686 Pointsvar questions = [
{question: 'blahblah', answer: 'blaahblaah', points: 3},
]
Maybe you could specify points for each question like above and when the question is answered correctly, you just access this points value.
something like this:
points += questions[i].points
Disclaimer: I did not test any of the code i wrote. If these ideas don't help you, please post your code and we will find a solution. I'm a beginner, too, so this is interesting to me. :)
Hirenkumar Patel
Courses Plus Student 9,464 PointsI think use dictionary that you can manage individual variable point of each question.