I need help figuring out how to use a for loop to iterate over data in order to populate my Google Chart. The code snippet below outlines what I've already tried.
var line_div = '2016-08-04,4|2016-08-05,7|2016-08-06,9|2016-08-07,2';
var line = line_div.split(/[,|]/);
var array_dt = line.filter((x,i) => (i%2!==0));
var array_s = line.filter((x,i) => (i%2===0));
var line_data = google.visualization.arrayToDataTable([
['Date', 'Log'],
['2016-08-04', 134]
]);
As seen below, I attempted to implement the for loop, but I'm struggling with the section marked as dots. I am aware that my approach is incorrect, yet I'm unsure of an alternative solution.
var line_data = google.visualization.arrayToDataTable([
for(var i = 0; i < line.length; i++) {
['Date', 'Log'],
[...]
}
]);
Any suggestions on how I can successfully achieve this task?