Skip to content

Instantly share code, notes, and snippets.

@mopig
Last active December 29, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mopig/7624625 to your computer and use it in GitHub Desktop.
Save mopig/7624625 to your computer and use it in GitHub Desktop.
For V2EX
//这里的错误就不纠正了
var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
}
};
var search = function(name){
for(var i in friends){
if(friends.i.firstName === name){
for(var j in friends.i){
console.log(friends.i.j);
return friends.i.j;
}
}else{
console.log("Not found");
}
}
};

看看支持 Markdown

@kalenderApp
Copy link

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
}
};

var s = function(name){
for(var i in friends){
if(friends[i].firstName === name){
console.log(friends[i]);
for(var j in friends[i]){
console.log(friends[i][j]);
//return friends[i][j];
}
}else{
console.log("Not found");
}
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment