Sunday, February 17, 2013
How to order objects... puzzled on the last function I somehow copied and ...
friends = {
ariane : {firstName: "Ariane",
lastName: "Bertram",
number: "696966123",
address: ["via bellezza 37", "Brasile", "53550"]},
bill : {firstName: "Bill",
lastName: "Porte",
number: "666 666666",
address: ["ta dah", "palle", "99"]},
steve : {firstName: "Steve",
lastName: "Dell'inferno",
number: "213456987",
address:["Oppa", "Gang nam", "57173"]}
};
var list = function (){
for (var names in friends){
console.log(names); }};
var search = function (name){
for (var contact in friends){
if (friends[contact].firstName===name){
console.log(friends[contact]);
return (friends[contact]);}}};
//In this exercise I quite didn't understand the function for/in, and the last part where 'friends[contact].firstName ... does it mean contact is in friends and start with firstName and I have to make it equal to name because I can give it the property of a function?!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please, comment!