What is wrong with my code?


#1


https://www.codecademy.com/courses/spencer-sandbox/4/2?curriculum_id=506324b3a7dffd00020bf661#

Exercise Loop the Loop (27)

I keep getting the error message "Oops, try again. There was a problem with your syntax."

Please help me find the flaw!


// Our Person constructor
function person(name, age) {
    this.name = name;
    this.age = age;
}

// Now we can make an array of people
var family = new Array();

var family[0] = new person("alice", 40);
var family[1] = new person("bob", 42);
var family[2] = new person("michelle", 8);
var family[3] = new person("timmy", 6);
// loop through our new array
for (i = 0; i< 4; i++) {
    console.log(family[i].name)
}


#2

One thing I noticed (probably not going to solve the overall problem) You are missing a semicolon after your console.log statement.


#3

I just figured it out actually.

I was declaring the array components as variables, which I shouldn't have been doing.

Thank you for the help!


#4

No problem :slight_smile: glad that you were able to figure it out :slight_smile: