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 trial4Ctech Admin
5,062 PointsRuby: Stage 3: Build A Simple Contact List Challenge not working
I don't get why this code isn't working. I tried a few things that didn't work and then just used the same code that Jason Seifer used in the video. I don't really get an error. The response is just "Bummer! Try again!"
contact_list = [
{"name" => "Jason", "phone_number" => "123"},
{"name" => "Nick", "phone_number" => "456"}
]
contact_list.each do |contact|
puts "Name: #{contact["name"]}"
if contact["phone_number"].size > 0
contact["phone_number"].each do |number|
puts "Phone Number : #{contact["phone_number"]}"
end
end
3 Answers
Salman Akram
Courses Plus Student 40,065 PointsHi,
They require only values without additional information, just simple like this without complicated. :-)
contact_list = [
{"name" => "Jason", "phone_number" => "123"},
{"name" => "Nick", "phone_number" => "456"}
]
contact_list.each do |contact|
puts contact["name"]
puts contact["phone_number"]
end
Hope that helps.
jessetoporowski
1,608 PointsIt's frustrating that most of the other answers allow things like
puts "Name: #{name}" and this one doesn't allow for anything extra.
sergiu cozma
14,774 PointsWhy doesn't this code works?
contact_list = [
{"name" => "Jason", "phone_number" => "123"},
{"name" => "Nick", "phone_number" => "456"}
]
contact_list.each do |contact|
contact.each_value do |v|
puts v
end
end
Maurice Tafolla- Cunningham
7,708 PointsMaurice Tafolla- Cunningham
7,708 PointsMy code looks exactly the same aside from my block choice.
It's frustrating when these challenges are deceptively simple.
I had to come here to the forum and see why I was getting the same error, so thanks for asking this question and helping me out!