-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」...他應該,因爲它在構造函數中。 –