7. Searching for Friends!


Hey friends :grinning:

The coding is allowing me pass to the next section, but the output is:


Any tips as to why I’m not producing the desired output?

var friends = {
bill: {
firstName: "Bill",
lastName: "Brown",
number: "(206) 555-5555",
address: ["One Microsoft Way", "Redman", "VA", "33333"]
steve: {
firstName: "Steve",
lastName: "Steverson",
number: "(456) 468-9852",
address: ["Twenty Two", "Beaverton", "OH", "444433"]
var list = function (friends){
for (var firstName in friends) {
var search = function(name) {
for (var key in friends) {
if (friends[key].firstName === name) {
return friends[key];


for the first console.log you are looping through friends and assigning each one to firstName, therefore firstName is actually the whole bill or steve object, not the firstName attribute of each one. so that should look more like your second loop.
for(var key in friends){

for the second console.log its because there is no object ‘firstName’ in friends you should have console.log(friends[key].firstName) ;


Thanks doggo! That helped a lot!


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