I'm just getting hands on JavaScript and I can't figure out how to increment by 1 the index selector with each click.
The following code is giving me the index 6, but I would like this index to increment with each click:
var nextCompanyLabel = 6;
label: label[nextCompanyLabel++],
This is the complete code:
$('#addDataset').click(function() {
var background = randomColor(0.5);
var nextCompanyLabel = 6;
var newDataset = {
label: label[nextCompanyLabel++],
borderColor: background,
backgroundColor: background,
pointBorderColor: background,
pointBackgroundColor: background,
pointBorderWidth: 1,
fill: false,
data: [],
};
for (var index = 0; index < config.data.labels.length; ++index) {
newDataset.data.push(randomScalingFactor());
}
config.data.datasets.push(newDataset);
window.myLine.update();
});
All help will be appreciated!
var nextCompanyLabel = 6;from the click