Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!