Lister tout les contacts

Yes i read but i don’t understand all code you write

ok post your code again…

It’s here
var bob = {
prenom: “Bob”
nom: “Jones”
téléphone: “01 23 45 67 89”
email: "[email protected]"
};

marie var = {
prenom: “Marie”
nom: “Johnson”
téléphone: “02 34 56 78 91”
email: "[email protected]"
};

contacts var = [bob, marie];

function affichePersonne (personne) {
console.log (personne.prenom + “” + personne.nom);
}

var liste = function () {

var longueurContacts = contacts.length;
for (var i = 0; i <longueurContacts; i ++) {
}
}

affichePersonne(contacts[i])

thid part

function affichePersonne (personne) {
    console.log (personne.prenom + "" + personne.nom);
}

you should only add the space betwen the “” in the console.log() liek that

console.log (personne.prenom + " " + personne.nom);

ok i’ts my fault i don’t read this part

1 Like

still not working

var bob = {
prenom: “Bob”
nom: “Jones”
téléphone: “01 23 45 67 89”
email: "[email protected]"
};

marie var = {
prenom: “Marie”
nom: “Johnson”
téléphone: “02 34 56 78 91”
email: "[email protected]"
};

contacts var = [bob, marie];

function affichePersonne (personne) {
console.log (personne.prenom + " " + personne.nom);
}

var liste = function () {

var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
}
}

affichePersonne(contacts[i])

then inside the for loop you should call the function affichePersonne()

for (var i = 0; i < longueurContacts; i++ )  {
    affichePersonne(contacts[i])
}

DId you passe the lesson?

No, he write (problem with your synthax)
var liste = function () {
var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
affichePersonne()
}
}

that

contacts var = [bob, marie];

should be

var contacts  = [bob, marie];

this part

affichePersonne()

you should pur inside the calling functon contacts[i] like that

affichePersonne(contacts[i])

inside function i put contacts[i] ?

yes inside the calling function like that

var liste = function () {
    var longueurContacts = contacts.length;
    for (var i = 0; i < longueurContacts; i++) {
        affichePersonne(contacts[i])
    }
}
1 Like

Ok, sitll not working

var liste = function () {
var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
affichePersonne(contacts[i])
}
}

this part

var bob = {
prenom: "Bob"
nom: "Jones"
téléphone: "01 23 45 67 89"
email: "[email protected]"
};

marie var = {
prenom: "Marie"
nom: "Johnson"
téléphone: "02 34 56 78 91"
email: "[email protected]"
};

it missing the , after each proprity inside each object
like that

var bob = {
    prenom: "Bob" ,
    nom: "Jones",
    téléphone: "01 23 45 67 89" ,
    email: "[email protected]" ,
};

the here

marie var = ..

should be

var marie = .. 

waouh!!
finally we succed thx very mutch bro

1 Like

The exercise send me my code is write, but also not valide my code hi say (propriete is not defined) when i’m wrong ?
function recherche (nom) {
var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
if (propiete[nom] === nom) {
affichePersonne(nom[i]);
}
}
}

recherche(“Jones”)

this part

if (propiete[nom] === nom) {
    affichePersonne(nom[i]);
}

propiete is not define so you should us contacts then the nom is the argument that should match to the contacts nom so inside the you should put the i from the for loop, so it should be lika that

if (contact[i].nom === nom) {
    affichePersonne(contacts[i]);
}

I add the .nom because it should match with the name you will put inside the calling funtion recherche

Did you passe the lesson?

i change the code, the problem the code is right but he send this message propriete is not defined and also accept the code why ?
function recherche (nom) {
var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
if (contacts[i] === nom) {
affichePersonne(contacts[i]);
}
}
}

recherche(propriete[nom])

here the instruction

5 En bas du fichier, appelez la fonction recherche en lui passant “Jones” comme nom à rechercher