Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Converts 2D array of JS objects into CSV formatted string.

1
2
3
4
5
6
7
8
export const objectToCsv = ((data: Object[]) => {
const headerRow = Object.keys(data[0]).join() + "\n";
let bodyRows = "";
data.forEach((element) => {
bodyRows += (Object.values(element).join() + "\n").toString();
});
return headerRow + bodyRows;
});
October 23, 2023