I have an array of objects. I want to filter them and then do something to the filtered objects. This is my attempt so far.
Positions Object
function Position (title, type, purchasable){
this.title = title;
this.type = type;
this.purchasable = purchasable || false;
}
function Purchasable (prices){
this.owner = "unowned";
this.rating = 0;
this.prices = prices;
this.price = this.prices[this.rating];
}
function City (title,set,prices){
Position.call(this, title, "city", true);
Purchasable.call(this, prices);
this.set = set;
}
positions = [
new City("Cairo", "brown", [60,2,10,30,90,160,250]),
new City("Vienna", "brown", [60,4,20,60,180,320,450]),
new City("Vienna", "blue", [60,4,20,60,180,320,450])
];
});
Function
function test() {
var set = "brown";
positions.filter(function(obj){
obj.set === "brown"; //do something to every brown set, eg owner = me
});
//I want to change the values of the objs in positions array
}
Cityobject?