How can I append a JSON like structure while iterating through a for loop?
For Example (Pseudo Code):
var i; for (i = 0; i < clients.length; i++) { date = clients.date; contact = clients.contact; }
My main goal is to append as many groups of: dates and contacts as the clients.length data holds.
I need each loop iteration to create something like below of multiple indexes of date and contact groups. My overall goal is to have a data structure like below created through my for loop.
Assume im just using strings for: "Date" & "Contact"
var data = [ { "Date": "2015-02-03", "Contact": 1 }, { "Date": "2017-01-22", "Contact": 2 } ];
clients = [ { date:'2015-02-03', contact: 1 },{ date:'2017-01-22', contact: 2 } ];
so siimplyresult = JSON.stringify(clients.map(({date, contact}) => ({Date:date, Contact:contact})))
clients
array?