I seem to know the reason why i am getting this error but i dont know how another way to solve this, the problem is giving error saying “name” and “quantity” is not a member of this object.
internal var myDrugs = new Array();
function buyDrug(drug : Drug) {
myDrugs.push(drug);
}
function getDrugs(index : int) {
return myDrugs[index];
}
function getDrugsLength() {
return myDrugs.length;
}
function sellDrug(name : String, amount : int) {
for (var i = 0; i < myDrugs.length; i++) {
if (myDrugs*.name == name) {*
_ if (myDrugs*.quantity <= amount) {_
_ myDrugs.quantity -= amount;
}
if (myDrugs.quantity == 0) {
myDrugs.RemoveAt(i);
}
}
}
}*_