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.

Continue Reading:

Generate Random Password

Published on January 26, 2024

javascriptpythonphp

Detecting Browser and Version

Published on January 26, 2024

javascript

Detect Dark Mode Preference

Published on January 26, 2024

javascript

Calculate Greatest Common Divisor (GCD) of Two Numbers

Published on January 26, 2024

javascript

Calculate Distance Between Two Points

Published on January 26, 2024

javascript

Validate Password Strength

Published on January 26, 2024

javascript

Parse JSON String to Object

Published on January 26, 2024

javascript

Data Import and Export in MySQL

Published on August 12, 2024

mysql