I have this array object which initiates each index:
var example = { 'hours': 0, 'overtime': 0, 'income': 0, 'expenditure': 0 };
However it is inside a .each()
loop. Each index needs a unique identifier like: hours0
hours1
.
The old format that I used to append a suffix is bulky.
example['hours' + index] = 0;
example['overtime' + index] = 0;
example['income' + index] = 0;
example['expenditure' + index] = 0;
I've tried the following.
var example = { 'hours'+index: 0, 'overtime'+index: 0, 'income'+index: 0, 'expenditure'+index: 0 };
But it results in: Uncaught SyntaxError: Unexpected token +
any ideas?