I have read many, many ways of making makeshift classes in javascript. I'm trying to create a giant list of items, each with a variety of variables. I need to be able to call a certain object's properties from this list. The following code compiles, but when line 9 tries to access items.yspeed1.name, it creates the button with the name "undefined". I have no clue how to access a function's variables in javascript like this.
var itemslist = function(){
this.yspeed1 = function(){
this.name = 'Yellow Upgrade';
this.price = 50;
}
this.yspeed2 = function(){
this.name = 'Blue Upgrade';
this.price = 25;
}
}
var newitem = document.createElement('button');
newitem.innerHTML = items.yspeed1.name;
shop.appendChild(newitem);