JSFiddle - React, Tailwind, and code Playground
JavaScript
var myarray = [{key:'12/10/2028', value:{Direct:2,Indirect:32,Unknown:-15}},
{key:'12/10/2028', value:{Direct:126,Indirect:82,Unknown:-15}},
{key:Thu Jan 01 2015 00:00:00 GMT+0530 (India Standard Time), value:{Direct:2,Indirect:72,Unknown:-15}},
{key:Thu Jan 01 2015 00:00:00 GMT+0530 (India Standard Time), value:{Direct:-12,Indirect:19,Unknown:-15}},
{key:Thu Jan 01 2015 00:00:00 GMT+0530 (India Standard Time), value:{Direct:112,Indirect:32,Unknown:-15}},
{key:Thu Jan 01 2015 00:00:00 GMT+0530 (India Standard Time), value:{Direct:120,Indirect:52,Unknown:-15}}
];
var row_width = 40;
var content = "";
content += "Username" + new Array(row_width + 1).join(" ") + "Password\n";
content += "********" + new Array(row_width + 1).join(" ") + "********\n";
for (var i = 0; i < myarray.length; i += 2) {
content += myarray[i] + new Array(row_width - myarray[i].length + 9).join(" ");
content += myarray[i+1];
content += "\n";
}
// Build a data URI:
uri = "data:application/octet-stream," + encodeURIComponent(content);
// Click on the file to download
// You can also do this as a button that has the href pointing to the data URI
location.href = uri;