In my code, I wish to be able to create functions under Game
that can be called like so:
Game.Player.iJava.showNum()
Which would return '5'
and
Game.Player.Bill.showNum()
Which would return '120'
I'm confused on the syntax to be able to call it like that, this is what I have so far Sorry if my description is vague, I am trying to explain this as best as I can but my English isn't very well
Thank you, here is what I have so far
var Username = 'iJava';
function Game(Object, Attribute, Number) {
this.Object = Object;
this.Attribute = Attribute;
this.Number = Number
this.showNum= function() { return Number;}
this.Create = function() { if (Object == "Player") { console.log("Created user "+Attribute) } };
}
function Player(Name, Num) {
new Game("Player", Name, Num);
}
var User = new Player(Username, 5)
var Bill = new Player("Bill", 120)