Search for a friend 7/8



Hello everyone,

I am a beginning programmer and I just had my first year of coding lessons, but I still have some issues with JavaScript. That's why I decided to start this course on Code Academy.

(sorry for my somewhat bad English, but English is not my primary language, therefore it may contain some errors but I hope you'll understand what I have to say)

I was stuck at this exercise for a pretty long time, and after some reviewing I finally got the message that my code was correct. I was happy!

But when I checked out what was logged, each contact was logged four times. And after these 4 logs, the same contacts were logged another time, but now horizontaly. I checked my code over and over again, but I can't seem to find the error.

Can anyone help me please, your help would be greatly appreciated!

var friends = new Object();

friends.bill = new Object();
friends.bill.address=["Maalbeekstraat", "Dilbeek", "Belgium", "1700"];

friends.steve = new Object();
friends.steve.address=["Maalbeekstraat", "Dilbeek", "Belgium", "1700"];
var list = function (contacts){
    for (var friend in contacts){

var search = function (name) {
    for (var firstName in name){
        return friends;



Codecademy doesn't redirect output when it's calling your code, and it also prints the result of the last expression, so some of that extra output could be from that. You can tell which that would be by adding a print statement at the very end of your code, anything that is printed out after that print will be caused by something other than your code.

If you're still getting duplicate prints above that print, then you'll just have to check all the places where you print something and consider how many times it executes/where that code is called.

For example your search function is both printing and returning, that is rather strange behaviour. Perhaps it's just meant to return.


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