我正在codecademy.com上学习一些JavaScript/jQuery课程.通常课程提供答案或提示,但对于这个课程,它没有给出任何帮助,我对说明有点困惑.
它说使makeGamePlayer函数返回一个带有三个键的对象.
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
}
Run Code Online (Sandbox Code Playgroud)
我不确定我是否应该这样做
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
this.name = name;
this.totalScore = totalScore;
this.gamesPlayed = gamesPlayed;
}
Run Code Online (Sandbox Code Playgroud)
或类似的东西
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
var obj = {
this.name …Run Code Online (Sandbox Code Playgroud) javascript ×1