Contact List - Search for a friend


#1

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: '(206) 709-3100',
address: ["One Microsoft Way"],
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: '(112) 565-3100',
address: ["Palo Alto"],
},
oskar: {
firstName: "Oskar",
lastName: "Brahtz",
number: '40855399',
address: ["Vissingsgade"],
},
ali: {
firstName: "Ali",
lastName: "Buheiri",
number: '12345678',
address: ["Loeget"],
},
};

var list = function (friends) {
for (var firstName in friends) {
console.log(firstName);
}
};

var search = function (name) {
for (var firstName in friends) {
if (friends[firstName] === name {
console.log(friends[firstName, lastName, number, address]);
return friends[firstName, lastName, number, address];
}
}
};

search("Oskar");

This is my code, and in stuck here, it says unexpected token {
Can someone help me? And tell me if im doing something wrong? :slightly_smiling:


#2

You forgot to close your if condition

if (condition)