Last active
December 29, 2015 05:49
-
-
Save mopig/7624625 to your computer and use it in GitHub Desktop.
For V2EX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//这里的错误就不纠正了 | |
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"); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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");
}
}
};