var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};
var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example.com"
};
var contacts = [bob, mary];
function printPerson(person) {
console.log(person.firstName + " " + person.lastName);
}
function add(firstName,lastName,email,phoneNumber)
{
}
我不知道如何以及在add函数中写什么来帮助我添加更多联系人。请帮我!感谢
答案 0 :(得分:0)
function add(firstName,lastName,email,phoneNumber) {
var test_user=
{
"firstName": firstName,
"lastName":lastName,
"phoneNumber": phoneNumber,
"email": email
};
contacts.push(test_user);
}