Estou tendo algumas aulas de JavaScript / jQuery em codecademy.com. Normalmente as aulas fornecem respostas ou dicas, mas para esta não ajuda em nada e fico um pouco confuso com as instruções.
Diz para fazer com que a função makeGamePlayer retorne um objeto com três chaves.
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
}
Não tenho certeza se deveria estar fazendo isso
//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;
}
ou algo parecido com isto
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
var obj = {
this.name = name;
this.totalScore = totalScore;
this.gamesPlayed = gamesPlayed;
}
}
Tenho que ser capaz de modificar as propriedades do objeto após sua criação.
newpalavra-chave que eu sugeriria começar o nome com um capital:MakeGamePlayer.