-1
function player(name, goals, games) {
this.name = name;
this.goals = goals;
this.games = games;
}
var ricky = new player('Ricky', 7, 15);
var tom = new player('Tom', 15, 17);
var phil = new player('Phillip', 9, 14);
var jerry = new player('Jerry', 11, 15);
var randy = new player('Randy', 4, 16);
var sam = new player('Sam', 5, 11);
function locTeams(name, town, wins, playerOne, playerTwo, playerThree) {
this.name = name;
this.town = town;
this.wins = wins;
this.playerOne = playerOne;
this.playerTwo = playerTwo;
this.playerThree = playerThree;
}
var tigers = new locTeams('Great Tigers', 'Clayton', 9, ricky, tom);
var pantheon = new locTeams('The Pantheons', 'Brookedale', 8, jerry, randy);
teams = [tigers, pantheon];
var totalGoalsState =
内对象的单个属性的值,我需要一个简单的方法有totalGoalsState
等于从teams
阵列中的玩家累计游戏者目的。另外,我如何填写playerThree
与其他新玩家之一,如phil
或sam
成为像老虎或万神殿之类的球队之一。总计所有对象
您的构造函数'locTeams'需要5个参数,要传递4.您错过有作为'this.playerThree = playerThree'。 –
@AleksandarĐokić - 它不需要* 5个参数,它*可以有* 5个参数。 – adeneo
@ adeneo是的,但他没有在方法中的任何地方设置“playerThree”...他应该,因为它在构造函数中。 –