Codeacademy课程JavaScript的问题

时间:2015-07-31 18:07:35

标签: javascript

我一直在尝试Codeacademy和我在一个你创建联系人列表的任务,下面是我编写的代码。但它不断得到错误“ 哎呀,再试一次。你有没有给你的每个朋友一个地址属性?“我不知道该怎么做..我试着在任务的论坛上发布这个问题,但没有解决这个问题的工作解决方案。

var friends = new Object();
friends.firstName = "George";
friends.lastName = "Georgsson";
friends.number = 5555555;
friends.address = ["Street streetsson" , "9011010", "Redmond"];


friends.bill = new Object();

friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = 132123123;
friends.bill.address = ["Microsoft Corporation" , "9011010", "Redmond"];



friends.steve = new Object();
friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = 51515151;
friends.steve.address = ["Apple Inc", "9011010", "Redmond"];

1 个答案:

答案 0 :(得分:1)

这是我在该模块上必须做的。我只是用下面的随机数据填写,但这应该对你有用。我只使用了2个朋友,我认为这就是你所需要的。

var friends = new Object();

friends.bill = {
firstName:"Bill",
lastName:"Scuba",
number:12,
address:["lol",2]
}

friends.steve = {
firstName:"Steve",
lastName:"Scuba",
number:12,
address:["lol",2]
}