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 trialNiki Torres
1,026 PointsAm I overthinking this challenge with this code?
Again, arrays seem to be so confusing for me. Either I'm completely not getting the instructions, overthinking it, or just darn confused by the whole thing.
The only error message I get on Treehouse is "Try again!". Not helpful at all. Can anyone have a look and tell me what's wrong? I tried running it on Workspace and it does print the array so I'm really really really confused.
def create_shopping_list
title = "Grocery List"
items = Array.new
puts "title: #{title}"
puts "items:" + items
return create_shopping_list
end
1 Answer
Grace Kelly
33,990 PointsHi Nikki, the challenge requires for you to only return a hash inside the create_shopping_list method, you don't need to output anything to the screen. We create a hash by doing the following:
hash = {"key" => "value"}
So by applying this code you can assign the keys "title" and "items" with their values "Grocery List" and an empty array (Array.new) for example {"title" => "Grocery List"}. Also remember that you need to return this hash :)
Hope that helps!!
Niki Torres
1,026 PointsNiki Torres
1,026 PointsI guess I am overthinking it. :P Thanks for the help!
Grace Kelly
33,990 PointsGrace Kelly
33,990 Pointsno worries!! glad to help!!