Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to solve chapter 9 question no. 9 my answer is matching with the output but it is not getting submitted find the error and correct me please.

let player = {
name: "default_name",
weapon: "Pistol",
exp: "Pro",

// defining method
setName: function(name) {
this.name=name;
},
getName: function() {
return(player.setName);
},
showInfo: function() {
console.log(`${this.name} uses ${this.weapon} and is ${this.exp} level player in STBattleRoyal`);
}
};

player.setName("John Wick");
player.showInfo();
by

1 Answer

abhishekkumarsingh
let player = {
name: "default_name",
weapon: "Pistol",
exp: "Pro",

// defining method
setName: function(name) {
this.name=name;
},
getName: function() {
return this.name;
},
showInfo: function() {
console.log(`${this.getName()} uses ${this.weapon} and is ${this.exp} level player in STBattleRoyal`);
}
};

player.setName("John Wick");
player.showInfo();

Login / Signup to Answer the Question.