i'm trying to create object named client. and put it into a array. And after this, read the name of the 1st client.
Exemple :
client1 {nom : "marco", prenom : "chedel", adresseMail : "ssss@ggg.com"};
and put this client into an array like bellow.
listClients[client1]
what i did :
var listClients = [];
var client1 = {nom : "chedel",prenom:"Marco",adresseMail:"marco@gmail.com"};
listClients.push(client1);
var client2 = {nom : "De Almeida",prenom:"Jorge",adresseMail:"jorge@gmail.com"};
listClients.push(client2);
function afficheClients(tableau){
for (i=0;i<tableau.length;i++)
{
var c = tableau[i];
document.write(c[adresseMail]);
// This ^^ doesn't work, it says :adresseMail isn't definied in c
}
}
afficheClients(listClients);
You're treating adressMail
as a variable and not as a string:
use
document.write(c["adresseMail"]);