this is my javascript
var inventory = [];
var money = 10;
function buyToInventory(what){
if(this.price>money){
log.unshift("D"+day+" "+hour+":"+minute+" - Poor hobo, you can't afford "+this.name+".<br>");
} else {
inventory.push=what;
money=money-this.price;
updateMoney();
};
};
function drinkable(name, price, effect){
this.name = name;
this.price = price;
this.effect = effect;
this.use = function(){
satisfy(thirst,this.effect,"#thirst")
};
};
var water = new drinkable("1l water", 1, 20);
Problem is when I write this in console buyToInventory(water). It seems like my function buyToInventory is totally wrong, it doesnt push water into the inventory array or when I set money = 0, it doesn't add that message about not having money. I can't figure out what am I doing wrong. Any help will help me a lot. :)
Thanks.
what.priceinstead ofthis.price. Here, if you really are callingbuyToInventory(water), thenthisis the globalwindowobject insidebuyToInventory.