Search for a friend..Function not found


Ive literally looked at every QA of this my code looks identical helllllp

Oops, try again.
Did you create a function called search?

var friends = new Object(); {

friends.bill = new Object(); {
    friends.bill.firstName = "Bill",
    friends.bill.lastName = "MC",
    friends.bill.number = 720,
    friends.bill.address = ["Infinite Loop","sw69 069"]
friends.steve = new Object(); {
    friends.steve.firstName = "Steve",
    friends.steve.lastName = "JayZ",
    friends.steve.number = 690,
    friends.steve.address = ["Deez nutz","Sww www"]

var list = function (friend) {
    for (var friend in friends) {


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


your search and list function seems fine, i would take a look at how your objects are constructor, i can't even decide which you are using (object constructor vs literal notation), i recommend you take a second how to construct the objects properly


I thought thats how you use object constructor...


no, the object constructor doesn't use curly brackets ({}), you can simply create the objects with the object constructor:

var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();

and then add the property's:

friends.steve.firstName = "Steve"

curly brackets are only used for the literal notation.


Sorry sir, Your code may be awesome in your point of view. but you will get unexpected result as you think. it might be helpful to you

var list = function (friend) {
// declare a variable as key to access
for (var key in friend) {


var search = function(name){

for (var key in friends){

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

     return friends[key];



■■■■ straight my code is awesome... thanks tho






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