What's wrong in the code?


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661

result is satisfactory but getting error message "
Oops, try again. It looks like you didn't log anything to the console."


`

Replace this line with your code.

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(055) 555 55555",
address: ['One Microsoft Way','Redmond','WA','98052']
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "(044) 444 44444",
address: ['One Microsoft Way','Redmond','WA','98052']
},
sekar: {
firstName: "Sekar",
lastName: "S.G.",
number: "(0335)333 33333",
address: ['One Microsoft Way','Redmond','WA','98052']
},
jk: {
firstName: "JayaKumar",
lastName: "K.P.",
number: "(022) 222 22222",
address: ['One Microsoft Way','Redmond','WA','98052']
}
};
var list = function(friends){
for(var friends in friends){
console.log(friends[list]);
}
}
var search = function(name){
for(var key in friends){
if(friends[key].firstName === name){
//console.log(friends[key]);
return friends[key];
}else{

     }
 } console.log("No Name found in friends list");

};
search("steve");


#2

var search = function(name){
for(var key in friends){
if(friends[key].firstName === name){
//console.log(friends[key]);
return friends[key];
}else{
console.log("No Name found in friends list");
}
}
};
search("Sekar");

if i place the console in else, am getting the result but code check and giving me unwanted lines also.


#3

Extra output is the result of the submission correctness test running the code a couple of times. So long as your result is first, the rest can be ignored.


#4

Thanks for your guidance


#5

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