Stuck on Lesson 7 - Search for a friend


I am really lost on this exercise. After a lot of re-working, checking other people's posts, ect, I've managed to get my code to return the 4 first names. I am still getting the error message

Oops, try again. It looks like your search function doesn't return contact information for Steve.

Can anyone point me in the right direction?

var friends = {

    bill:  {
        firstName: "Bill",
        lastName: "Gates",
        number: 555-123-4567,
        address: ["1 Microsoft st", "Washington"]
    steve:  {
        firsName: "Steve",
        lastName: "Jobs",
        number: 666-123-4567,
        address: ["2 Apple st", "California"]
    mike: {
        firstName: "Mike",
        lastName: "Jordan",
        number: 250-555-5555,
        address: ["1234 fake st", "USA"]
    will: {
        firstName: "Will",
        lastName: "Smith",
        number: 250-666-6666,
        address: ["4321 America dr", "USA"]


var friendList = function (contacts) {
    for (var x in friends) {
        console.log (x);

var search = function (name) {
    for (var y in friends) {
            if (friends[y].firstname === name) {
                 console.log (friends[y]);
                 return (friends[y]);
friendList (friends);
search ("Steve");


there are two problems, one is here:

if (friends[y].firstname === name)

firstName should have a uppercase N

then the second problem:

firsName: "Steve",

a t is missing in firstName


Always check carefully for typing errors. They are among the most common of errors.

This works only because friends is accessible outside of the function. You can keep the parameter contacts, but should also use it in the loop:

for x in contacts


Doh! I can't believe the solution was so simple! Thanks, I was about to tear my hair out!


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