I want to split a string by commas and then add them to an array. So far I have the following:
var temp = new Array();
temp = element.innerHTML.split(",");
for (i = 0; i < temp.length; i++) {
  var data = [{
    type: 'image',
    src: '/resources/'+ temp[i],
  },
}];
However, at the moment, if I run this it will reset the value of data everytime. How could I change it so that for each of my array values it adds to the data array?
 
     
    