dataPoints: [
for(i = 0;i<json.data.length;i++){
{ label: json.data[i][1], y: parseInt(json.data[i][2])}
}]
I have code like that but I see an error on the console
SyntaxError: missing ‘of’ after for
Does anyone know why? I did search on Google, but nothing can tell me why.
Advertisement
Answer
Obviously, You will get incorrect syntax. Seems you want to create an array so use Array.map()
dataPoints: json.data.map(function (d) {
return {
label: d[1],
y: parseInt(d[2])
}
})