27. Loop the loop, passed...but


#1


I got a pass for the code. However, only "timmy" prints out in the console. Shouldn't the console show all 4 family members in order that was coded? What am I doing incorrectly that only "timmy" prints to console?


 // 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();
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++) {
    console.log = (family[i].name);
    
};


#2

Try removing the equals sign
console.log = (family[i].name);


#3

The solutions to my problems always amazes me.......actually it makes me do a lot of head shaking!!! Thanks for your help!


#4

Fiz assim e deu certo!

// Nosso construtor Person
function Person (name, age){
this.name = name;
this.age = age;
};

// Agora podemos formar um array de pessoas
var family = new Array();
family[0] = new Person("alice" ,40);
family[1] = new Person("bob" , 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);

// percorra o novo array
for( var i = 0 ; i< family.length; i++){
console.log (family[i].name);
}


#5

try,
not using that .name in console.log!!!


#6

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