#27 Loop the loop - tried everything I can think of!



ReferenceError: newArray is not defined

Oops, try again. It looks like the object at index 0 was not created with the Person constructor

// Our Person constructor
function Person (name, age) {
    this.name = name;
    this.age = age;
// Now we can make an array of people
var family = newArray();
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);
// loop through our new array
for (i = 0; i < family.length; i++) {


The correct way to do it would be new Array();
Hope I Helped :slight_smile:


Oh wow, just needed a space, thanks!!


it proceeds without var, why is that?


I found here some example on declaring variable i in loop.
And for array, for the assignment you can write var family = new Array(); but in practice no one does that because there is simpler and faster solution like:
var family = []; and this gets you new, empty array saved in variable called family.


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