//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
gamePlayerObject = {
"name" : name,
"totalScore" : totalScore,
"gamesPlayed" : gamesPlayed
};
return gamePlayerObject;
}
//Now the object modifier
function addGameToPlayer(player,score) {
//should increment gamesPlayed by one
//and add score to totalScore
//of the gamePlayer object passed in as player
player.gamesPlayed++;
player.totalScore = player.totalScore + score;
}
No comments:
Post a Comment