7/8 search names


#1

var friends = {
Bill: {
firstName:"Bill",
lastName: "Gates",
number:061585624,
address: ['One microsoft way', 'virginia']
},
Steve: {
firstName:"Steve",
lastName: "Jobs",
number:061585625,
address:['Caramel Aplle', 'virginia']
}
};
var search = function(friends) {
for(var firstName) {
if(firstname == Steve || Bill){
console.log(firstName, lastName,number,address)
}
else{console.log("something went wrong")};

};

}

I have no clue how to solve this.


#2

The code is really confusing, can you tell me what you where trying to do? It looks like you have defined objects inside objects, and inside those objects you defined arrays? I can tell you some syntax errors I found quickly. This are the lines corrected
1)

 else{
console.log("something went wrong"); // I added this last semicolon
};

2)

if(firstname == "Steve" || "Bill"){ //I added the double quoation marks as they are strings. I'm not really sure but maybe you should add parenthesis around ("Steve" || "Bill")

Please let me know what you were trying to do there. Re-post your code with the 2 corrections I made and with comments explaining what you tried to do around different places (mainly the beginning).


#3

I was confusing myself. finily figured it out by looking back at the first
Exercise. Thank you for the effort


#4

I stuck in this code. It throws syntax error. But I couldn't figure it out. Please help me... Do we need to remove the list function here?

var friends = {
bill: {
firstName: "Bill",
lastName: "Murray",
number: "(206) 555-5555",
address: ['Pine Garden Lane', 'Dunwoody', 'GA', '30338']
},
steve: {
firstName: "Steve",
lastName: "Waugh",
number: "(245)-158-1561",
address: ['Junior Avenue', 'Atlanta', 'GA', '30318']
}
}
var list = function(friends) {
for (var firstName in friends) {
console.log(firstName);
}
}
var search = function(friends) {
for (var firstName) {
if (firstName === "Bill" || "Steve") {
console.log(firstName, lastName, number, address);
} else {
console.log("No results found.");
}
}
}
search (steve);