const employees = [ {id: 1, name: "Erős István", city: "Szeged", salary: 357 }, {id: 2, name: "Csendes Iván", city: "Szeged", salary: 352 }, {id: 3, name: "Lára Abigél", city: "Pécs", salary: 359 }, {id: 4, name: "Dér Gedeon", city: "Pécs", salary: 352 }, {id: 5, name: "Csor Krisztina", city: "Szeged", salary: 353 }, ]; function exportToCsv(data, filename) { const header = Object.keys(data[0]).join(','); const rows = data.map(obj => Object.values(obj).join(',')); const csvContent = [header, ...rows].join('\n'); const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = filename; link.click(); } const exportButton = document.getElementById('exportButton'); exportButton.addEventListener('click', () => { exportToCsv(employees, 'employees.csv'); });