Biorę lekcje JavaScript / jQuery na codecademy.com. Zwykle lekcje dostarczają odpowiedzi lub podpowiedzi, ale w tej nie pomagają i jestem trochę zdezorientowany instrukcjami.
Mówi, aby funkcja makeGamePlayer zwracała obiekt z trzema kluczami.
//First, the object creator
function makeGamePlayer(name,totalScore,gamesPlayed) {
//should return an object with three keys:
// name
// totalScore
// gamesPlayed
}
Nie jestem pewien, czy powinienem to robić
//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;
}
lub coś w tym stylu
//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;
}
}
Muszę mieć możliwość modyfikowania właściwości obiektu po jego utworzeniu.
newkluczowych Proponuję rozpoczęcie nazwę z kapitałem:MakeGamePlayer.