VICTORY! Contact list, Lesson 8


I'm just wondering if someone can explain how to answer the question when the prompt asks; "How might you format the output to look like this?

First Name: Steve
Last Name: Jobs
Number: (408) 555-5555
Address: 1 Infinite Loop
         Cupertino, CA 95014


what code do you have so far? I can help you, but wasn't planning to program everything for you


I've moved on to the next lessons at this point after trying my hand at it with no avail. Granted I didn't try for very long because I would like to finish the course! This is what I tried to do however I would get undefined values. What I tried to do was change the function:

var search = function(name) {
    for (var entry in friends) {
        if (friends[entry].firstName === name) {
            console.log("First Name: " + friends[firstName])
            console.log("Last Name: " + friends[lastName])
            console.log("Number: " + friends[number])
            console.log("Address: " + friends[address])


I knew there had to be a more efficient way of doing this but my knowledge of Javascrip is limited but growing at this point so I thought I could learn the concept later on in the course or in a different couse.


At this point I've tried different variations because I can't understand why I'm getting undefined values.

"First Name: " + friends.firstName

"First Name: " +

"First Name: " + friends[firstName]


Hello @awshin,

Can you put your full code as you're almost at end of this section, It will be easy to debug if you put your complete code here ?



if (friends[entry].firstName

you do it right, you want the firstName of your current friend/entry, so if you then want to log the first name you get:

console.log("First Name: " + friends[entry].firstName)

we have friends object, which contain two more objects (bill and steve, represented as entry with help for in loop), and then bill and steve have firstName, lastName and so on property


Thank you very much! upon finishing the section about objects I was also able to get different solutions to my problem! Thank you again very very much for all your help :smiley:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.