javascript
Published on January 26, 2024By DeveloperBreeze
// Example data as an array of objects
const data = [
{ name: 'John', age: 30, city: 'New York' },
{ name: 'Alice', age: 25, city: 'San Francisco' },
{ name: 'Bob', age: 35, city: 'Los Angeles' }
];
// Convert array of objects to CSV format
const csvContent = data.map(obj => Object.values(obj).join(',')).join('\\n');
// Log the generated CSV content to the console
console.log('CSV Content:', csvContent);
Comments
Please log in to leave a comment.