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 trial

Ruby Ruby Loops Build a Simple Contact List Assigning Hash Values From Methods

Rafael Flores
PLUS
Rafael Flores
Courses Plus Student 22,056 Points

Exercise 3 Build simple contact list:Append to contact_list array. What am i doing wrong?

This is the code that I presented on this exercise. I tested this on the threehouse console and it worked. However I am getting a message on the exercise, saying that I need to go back to exercise one. Does anyone know?

contact_list = []

def get_name() a = "Rafael" return a end

def get_phone_number answer = "7875258367" return answer end contact = {"name" => "", "phone_number" => "" } contact["name"] = get_name() contact["phone_number"] = get_phone_number()

contact_list.push(contact)

contact.rb
contact_list = []

def get_name()
  a = "Rafael"
  return a
end

def get_phone_number
  answer = "7875258367"
  return answer
end
contact = {"name" => "", "phone_number" => "" }
contact["name"] = get_name()
contact["phone_number"] = get_phone_number()

contact_list.push(contact)

1 Answer

Hi Rafael,

I think, you have added alot of extra codes than the specific question. Just follow exactly what the challenge ask you to do without extra codes.

Hope that helps.

-Salman