gpt4 book ai didi

javascript - 我的 JavaScript 代码出了什么问题

转载 作者:行者123 更新时间:2023-11-28 19:56:37 26 4
gpt4 key购买 nike

这是我正在做的练习:http://www.codecademy.com/courses/building-an-address-book/0/3?curriculum_id=506324b3a7dffd00020bf661#

Here is my code:

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];

// printPerson added here
function printPerson(person){
console.log(firstName);
console.log(lastName);
};

function printPerson(){
console.log(contacts[0]);
}
function printPerson(){
console.log(contacts[1]);
}

最佳答案

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];

// printPerson added here
function printPerson(person){
console.log(person.firstName + " "+ person.lastName);
}

printPerson(contacts[0]);
printPerson(contacts[1]);

关于javascript - 我的 JavaScript 代码出了什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22430079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com