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 trialBrian Patterson
19,588 PointsNot sure what is wrong
Not sure what is wrong.
hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 }
1 Answer
Stephen Beckstrand
11,169 PointsHey Brian,
Your question does not seem to have much information, in fact, it does not seem like it even includes any of the code you have already tried. Going forward it would be best to include as much information as possible in your question to get the best possible answer.
In this challenge, it wants you to check if there is a key called "calories" within the hash called "hash" using the has.key method. If it does, it wants you to set a variable of food to "true". This is possible with the following code:
hash = { "name" => "Bread", "quantity" => 1, "calories" => 100 }
if hash.has_key?("calories")
food = true
end
If this does not answer your question, just let us know and then provide as much detail as possible so we can better help you.
Brian Patterson
19,588 PointsBrian Patterson
19,588 PointsThanks for the reply.