I have a question as to why this is not working. Noob question, probably.
var itemCheck = {
darkBerries: 0
}
var id = darkBerries;
itemcheck . id ++;
Thank you.
I have a question as to why this is not working. Noob question, probably.
var itemCheck = {
darkBerries: 0
}
var id = darkBerries;
itemcheck . id ++;
Thank you.
If I understand correctly, you want to increment the darkBerries
property using the id
variable. To do that you have to save a string in the id
and use the brackets notation to access the object's property:
var itemCheck = {
darkBerries: 0
};
var id = "darkBeries";
itemCheck[id]++;