Nevermind, I fixed it! //6 We made a friend, I'm stuck!


#1

Hello everyone! I'm really having fun with this JavaScript programming, but for the first time I'm stuck. I've been reading all the posts on the forum about this "add a new friend" thing, and I really cannot find my mistake... The message it gives me is "ReferenceError: personne is not defined" and apparently I still have 2 items and not 3. Please, is there anyone who can help? Oh, and Happy New Year!

`var bob = {
prenom: "Bob",
nom: "Jones",
telephone: "01 23 45 67 89",
email: "bob.jones@exemple.com"
};

var mary = {
prenom: "Mary",
nom: "Johnson",
telephone: "02 34 56 78 91",
email: "mary.johnson@exemple.com"
};

var contacts = [bob, mary];

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

function liste() {
var longueurContacts = contacts.length;
for (var i = 0; i < longueurContacts; i++) {
affichePersonne(contacts[i]);
}
}
function recherche(nom){
var longueurContacts=contacts.length;
for(var i=0;i if(personne.nom===nom){
affichePersonne(nom);
}else{}
}
}
recherche("Jones");
function ajout(prenom,nom,email,telephone){
contacts[contacts.length] ={
prenom: prenom,
nom: nom,
email: email,
telephone: telephone
} ;
};
ajout("name","last","person@ex.com","(888) 888-8888");
list();

/*Créez une fonction de recherche
puis envoyez lui "Jones"*/`


#2

Hi, try this:

function ajout(prenom,nom,email,telephone){

var newContact = new Object();
newContact.prenom = prenom;
newContact.nom = nom;
newContact.email = email;
newContact.telephone = telephone;
contacts[contacts.length] = newContact;
};


#3

A tad quicker would be:

function add(firstName,lastName,phoneNumber,email){
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
};

add("Steve","Smith","456 - 555-8989","steve.smith@example.com")

list()