I have this response from my ajax
and this is my configs.objects
configs.objects = ['Mexico','Brazil','Spain','Italy','USA'];
(7) [19, 51, 40, 69, 15, 77, 40]
I created a for-loop
var datasets = [];
for (i = 0; i < configs.objects.length; i++) {
console.log(i);
datasets[i]['borderWidth'] = 1;
datasets[i]['hoverBorderWidth'] = 2;
datasets[i]['hoverBorderColor'] = '#fff';
datasets[i]['data'] = response[i];
datasets[i]['label'] = configs.objects[i];
// debugger;
}
console.log(datasets);
I kept getting
Uncaught TypeError: Cannot set property 'borderWidth' of undefined
Why ? Am I doing anything wrong ? I've been staring at this codes for the last 2 hours.
I can't tell why I kept getting that error.