这就是我要解决的问题
var name;
var totalScore;
var gamesPlayed;
var player;
var score;
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
o = {
'name' : name,
'totalScore' : totalScore,
'gamesPlayed' : gamesPlayed
};
return o;
}
//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
if(player == name) {
gamesPlayed += 1;
totalScore += score;
}
}
但是如果现在我使用的第二个函数应该是别的东西......我该如何比较这两个?(它来自学习 JS 的练习)