Here is a part of the tutorial from Codecademy.
The instruction is:
Show the name of each member in the array by "For"
function Personne (nom, age)
{
this.nom = nom;
this.age = age;
};
var famille = new Array();
famille[0] = new Personne("alice", 40);
famille[1] = new Personne("bob", 42);
famille[2] = new Personne("michelle", 8);
famille[3] = new Personne("timmy", 6);
for( i=0; i<famille.length; i++)
{
console.log( famille[i] );
};
Which means I need to show:
alice
bob
michelle
timmy
but with the "For" that I wrote, it shows everything like
{ nom: 'alice', age: 40 }
{ nom: 'bob', age: 42 }
{ nom: 'michelle', age: 8 }
{ nom: 'timmy', age: 6 }
According to the tutorial's instruction, I have to creat the array like that
So what is the correct way to get only the name(nom) of each member?
Thanks for those who can help me!