7. Search for a Friend



Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token var

I can't figure out which var is not necessary in my code.

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "206 555-5555",
        address: ["One Microsoft Way","Redmond","WA","98052"],
    steve: {
        firstName: "Steve",
        lastName: "Martin",
        number: "302 555-5445",
        address: ["725 Vandever Avenue","Los Angeles","CA","10276"],
    helen: {
        firstName: "Helen",
        lastName: "Featherer",
        number: "813 347-3523",
        address: ["13906 Henson Circle","Tampa","FL","33625-}"],
    var list = function(friends) {
        for(var x in friends) {
    var search = funtion(name) {
        for(var key in friends) {  
            if(friends[key].firstName === name) {
            return friends[key];


The unexpected var is the start of the search() function. The list() function body is not closed.

    var list = function(friends) {
        for(var x in friends) {
    };    // this curly brace is missing

Both functions are currently inside the object enclosure, which will cause an error to be raised. Move them outside, to just below the object closing curly brace.


Thank you for your response. I took the var out and it didn't make a difference. I'm confused about your other comment. Can you please clarify?


It was not necessary to remove the var keyword, which is necessary, btw, just insert the missing curly brace as indicated.

After the helen object, add one more closing brace to close the friends object enclosure.

var friends = {
    bill: {},
    steve: {},
    helen: {}

var list = function () {


var search = function () {