I'm new to learning Javascript. at this stage, I want to use/decalre/initialize an array of objects.
Here is my code to initialise an object :
function player(name){
this.name = name;
this.getName = function(){
alert(this.name);
}
}
and here is where I need to use the array of players(objects)
function hallOfFame(nbrPlayers){
var arrayOfPlayers = []
}
Can anyone help me please how to create this array of objects. Thank you in advance :)
nbrPlayers?var arrayOfPlayers = [ new player('Elitia'), new player('Mike') ];See MDN's documentation for more examples.