Search for friends


var friends = new Object()
friends.bill = new  Object()
friends.steve = new Object()
var friends = {
bill: {
    firstName: "Bill",
    lastName: "Griffin",
    number: "1234567",
    address: ['Raspberry road ' , 'Sint Peters']
    var friends = {
            firstName: "Steve",
            lastName: "Jobs",
            number: "24681012",
            address: ['Wesly street' , 'Colebay']
    var list  = function(friends)
        for( var key in friends)
    var search = function (name){ 
    for(var key in friends){
        if ( friends[key].firstname === name ){
        return friends[key]


What is wrong with my code? it doesnt return the information for steve


the property is firstName, look what you use in your search function


oh i see i my typed firstName


now it isn't returning the information for bill


you make a friends object with one property: bill

then you make a new friends object with one property: steve

So what do you have then in the end? one friends object with one property (steve)


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