Getting some odd results


var friends = new Object();

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(395) 443-4543",
        address: ['One Microsoft Way','Redmond','WA','98052'],
    steve: {
        firstName: "Steve",
        lastName: "Jones",
        number: "774-857-9964",
        address: ['78495 Strattleburg Crt','Wilbur','AK','12548']
    carl: {
        firstName: "Carl",
        lastName: "Johnson",
        number: "552-145-6375",
        address: ['6969 BS Pkwy', 'OhYeah', 'NJ', '55489']

var list = function(friends) { 
    for (var r in friends) {

var search = function(friends) {
    for (var h in friends) {
        if ( friends[h].firstName === "Bill" || "Steve" || "Carl" ) {
            return friends[h];
        else {
            console.log("Sorry bro I don't have that name listed");

This is resulting in the following log to console:


  1. Contact List ( )

Also tried it with

if ( friends[h].firstName === name )

with resulting log to console:

Sorry bro I don't have that name listed
12x, or the number of keys in object?

Furthermore, both resulted in the following error message:

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

Any help is much appreciated!



from the instructions:

Define a function search that takes a single parameter, name

your function has friends as parameter

Name will contain the name you are searching for:

var search = function(name){

so you can use name in your if condition


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