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 trialMinca Daniel Andrei
6,245 PointsI don't understand what should I do here, I tried all the possible examples and still I can't pass...
I tried with grocery_list['items'] = grocery_item
and it still fails!
What else should I try ? Can't pass this...
grocery_list = { 'title' => 'Grocery List', 'items' => [] }
grocery_item = { 'title' => 'Bread', 'quantity' => 1 }
I have to include the grocery_item hash in the "items" value array from grocery_list...
2 Answers
Minca Daniel Andrei
6,245 PointsAfter struggling to get it work, I finally realised that I was working with an Array and had to use .push to insert that hash in it.
grocery_list = { 'title' => 'Grocery List', 'items' => [] }
grocery_item = { 'title' => 'Bread', 'quantity' => 1 }
grocery_list['items'].push(grocery_item)
And success! I'll keep this in mind for my whole life :)
Minca Daniel Andrei
6,245 PointsThank you Salman Akram Wish you the best!
Salman Akram
Courses Plus Student 40,065 PointsSalman Akram
Courses Plus Student 40,065 PointsAwesome!
I was planning to reply your question, however, you already solve the issues, glad you found it.
Happy Coding!