Return and console.log


#1

var friends = {};

friends.bill = {
firstName: ‘Bill’,
lastName: ‘Steveston’,
number: ‘074332164’,
address: [‘New York’,‘street Jefferson’, ‘bl. I8’, ‘nr.8’]
};

friends.steve = {
firstName: ‘Steve’,
lastName: ‘Geferson’,
number: ‘076345589’,
address: [‘London’, ‘street Bunkingam’, ‘bl. I13’, ‘nr.11’]
};

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

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

}

list(friends);
search(‘Bill’);

In the last function, why we need to use console.log and return in the same time?


#2

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