7/8 "It looks lika search function doesn't return contact information for Steve


Helo, please help me, here is my code:

var friends = {};
friends.Bill = {
firstName: "Bill",
lastName: "Gates",
phoneNumber: "48113327",
address:["Kongsteinsvegen", "Strand", "Tau", "4120"],
friends.Steve = {
firstName: "Steve",
lastName: "Jobs",
number: "49493929",
address: ["One Microsoft Way", "Redmond", "WA", "98052"],


var list = function(obj) {
for(var key in obj) {

var search = function(name){
for(var key in friends) {
if(friends[key].firsName === name) {
return friends[key];
else {
return "No match found"


Why doesn't it work?


Instead of

if(friends[key].firstName === name)

you put

if(friends[key].firsName === name)

It's just a little typo that would be hard to spot.

Hope it helped! :smile:


Thank you! I fixed it, but I get the same "Oops, try again! message".
But now this is what`s printed in the console:

Bill Steve { firstName: 'Bill', lastName: 'Gates', phoneNumber: '48113327', address: [ 'Kongsteinsvegen', 'Strand', 'Tau', '4120' ] } "No match found"

So, to me it looks like Im printing.
Both first names, then all of the content in Object "Bill".
And then it prints the console.log string in the else part of the if/else statement.

Any Ideas? :smile:



This is my code:

var friends = {};
    friends.bill = {
        firstName: "Bill",
        lastName: "Parl",
        number: "(666) 452-6138",
        address: ['Valley Way' , 'Montey', 'CA' , '94568']
    friends.steve = {
        firstName: "Steve",
        lastName: "Unot",
        number: "(334) 614-7823",
        address: ['Dell City' , 'Vancouver', 'CA' , '97358']

var list = function(obj){
    for(var key in obj){

var search = function(name){
    for(var key in friends){
        if(friends[key].firstName === name){


There may be another problem in your code, for I can not see any other problem. This code should work, for it works with mine.

Try it! :wink: If it doesn't work... Sorry I'm not the best debugger.


Thank you!
I compared your code with mine, and found a couple of more errors.


In your search function you are using a return-statement in your ELSE code-block.
change this into
console.log("No match found");

The return-statement causes an EXIT from your current-function-scope,
in your Original search function 'Steve' would never be found.

= = = = = = = = = = = = = = = = = = =


google search
=the book=
javascript variable site:developer.mozilla.org
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals
javascript return statement site:developer.mozilla.org
= https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
javascript return statement site:stackoverflow.com
= http://stackoverflow.com/questions/3717420/is-there-a-benefit-to-using-a-return-statement-that-returns-nothing
= http://stackoverflow.com/questions/22134753/return-statement-in-javascript


nice to know

You could test in labs.codecademy.com
choose Javascript
You will get a split-screen
In the left-hand-side you paste-in your code
click on the Run button.
The right-hand-side is the console


= www.crockford.com --> for most respected guide-line in Javascript
like coding convention
= www.crockford.com
= http://javascript.crockford.com/code.html
= http://javascript.crockford.com/survey.html


I found out what the problem was.. turns out the codecademy editor is EXTREME nit picky. I was scratching my head for a good 30 minutes and it kept saying "Looks like search function doesn't return contact information for Steve"

Turns out that you need to put a CAPITAL (S) in Steve. I had mine with all lower case and it kept bugging me so much. Capitalized the first letter in the name and voila! problem solved.


I don't understand why this code isn't working.
It gives me the error "Oops, try again. It looks like your search function doesn't return contact information for Steve."

Please help me out.

var friends=new Object();
friends.Bill= new Object();
friends.Steve=new Object();


var list = function(contacts)
for(var key in contacts)


var search=function(name)
for(var key in friends)
if(friends[key].firstname === name)
return friends[key2];



Oops, Please ignore. I got the ERROR. I was using firstname instead of firstName.


...Don't the directions say to find the name using Steve's last name? (I think)


And you are using:

that will not function either...