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

JavaScript

Is This Bad Practice With Objects?

Hello,

I've made a side project to randomly generate an assigned chore to a person. I decided that I'd like to practice using objects to do this, so I created an array of 5 or so objects with a 'name' and 'task' key each.

Then I created a function that randomly selected one of each key and printed them to the document.

I know I could have probably just used a 2-D array, but I wanted to use objects since that's what I'm learning about recently. Was this a good way to use objects, or did I choose a bad way to implement them?

1 Answer

I personally think it was a good idea :+1: The code should be more readable this way. It would be confusing to use a multi-dimensional array.