Ruby Ruby Collections Ruby Hashes Working with Hash Keys

geet bhullar
geet bhullar
953 Points

not sure why my answer is getting not working

i am not sure why this code is not passing the excercise

hash = { "name" => "Bread",
         "quantity" => 1, 
         "calories" => 100 }

if hash.has_key?("calories")
  food = true

1 Answer

Jay McGavren
Jay McGavren
Treehouse Teacher

Your code is fine. The tests for this challenge were written in such a way that if someone modified the existing code, even just to add whitespace, the challenge wouldn't pass.

That should be fixed now, so if you resubmit this exact same answer, it should pass. Sorry for the trouble!