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

Ruby Ruby Collections Build a Grocery List Program Working with Hashes That Contain Arrays

Make a grocery list Challenge 1 Task 1

I do not understand

shopping_list.rb
grocery_list = { 'title' => 'Grocery List', 'items' => [] }
grocery_item = { 'title' => 'Bread', 'quantity' => 1 }

hash =  {  grocery_list => grocery_item, 'items' => [] }

1 Answer

Sage Elliott
Sage Elliott
30,003 Points

Hello, Sara! Sometimes the question can be confusing! I had to read it a couple times again even though I completed it before. It's asking you to put the "grocery_item" hash to the items array INSIDE of the grocery_list hash The items hash is already there in the first line! The code should look something like below:

grocery_list['items'].push(grocery_item)

If that still doesn't make sense I'd suggest watching the video again. Often I just find the wording in the challenges to throw me off though. Code on!