JavaScript
x
5
1
dataPoints: [
2
for(i = 0;i<json.data.length;i++){
3
{ label: json.data[i][1], y: parseInt(json.data[i][2])}
4
}]
5
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()
JavaScript
1
7
1
dataPoints: json.data.map(function (d) {
2
return {
3
label: d[1],
4
y: parseInt(d[2])
5
}
6
})
7