#6 Did i do this right?


#1

so my code goes through...

var friends = {};
friends.joe = {
firstName: 'Joe',
lastName: 'Escob',
number : '(702-182-1023)',
address: ['1023 None of your business drive', 'Las Vegas', '\ Nevada', ' 89054']
};
friends.harambe = {
firstName: 'Harambe',
lastName: 'The Gorilla',
number: '(513-226-2620)',
address: ['7890 I got shot Rd', 'Cincinnati', 'Ohio', ' 73515']
};
friends.bill = {
firstName: 'Bill',
lastName: 'Nye',
number: '(716-847-0110)',
address: ['264 Earth Drive', 'New York City', ' New York', '73343']
};
friends.steve = {
firstName: 'Steve',
lastName: 'Bald',
number: '605-736-8367',
address: ['635 Apple Way', 'San Fransico', 'California', '89003']
};
var list = function(obj) {
for( var prop in obj) {
console.log(prop);
}
};

but...the console reads all the names plus "Steve's" info...is that what it should be doing??

joe
harambe
bill
steve
{"firstName":"Steve","lastName":"Bald","number":"605-736-8367","address":["635 Apple Way","San Fransico","California","89003"]}


#2

its doing it again, in #7. I cant tell what i did wrong. its bring up all the names and information rather than just the single friend name....

var friends = {};
friends.joe = {
firstName: 'Joe',
lastName: 'Escob',
number : '(702-182-1023)',
address: ['1023 None of your business drive', 'Las Vegas', '\ Nevada', ' 89054']
};
friends.harambe = {
firstName: 'Harambe',
lastName: 'The Gorilla',
number: '(513-226-2620)',
address: ['7890 I got shot Rd', 'Cincinnati', 'Ohio', ' 73515']
};
friends.bill = {
firstName: 'Bill',
lastName: 'Nye',
number: '(716-847-0110)',
address: ['264 Earth Drive', 'New York City', ' New York', '73343']
};
friends.steve = {
firstName: 'Steve',
lastName: 'Bald',
number: '605-736-8367',
address: ['635 Apple Way', 'San Fransico', 'California', '89003']
};
var list = function(obj) {
for( var prop in obj) {
console.log(prop);
}
};
var search = function(name) {
for(var prop in friends) {
if(friends[prop].firstName === name) {
console.log(friends[prop]);
return friends[prop];
}
}
};
list(friends);
search('joe');


#3

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