From 8000f59a2cd3ae4e1c3d8bca82a46f37f7cc8369 Mon Sep 17 00:00:00 2001 From: Facundo Saucedo <43495919@terciariourquiza.edu.ar> Date: Mon, 25 May 2026 12:36:28 -0300 Subject: [PATCH] feat: add employee table with average salary calculation --- ejercicio6/ejercicio6.js | 42 ++++++++++++++++++++++++++++++++++++++++ ejercicio6/index.html | 4 +++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ejercicio6/ejercicio6.js b/ejercicio6/ejercicio6.js index 6ce9e92..646d443 100644 --- a/ejercicio6/ejercicio6.js +++ b/ejercicio6/ejercicio6.js @@ -1 +1,43 @@ // Agregar aquí el código javascript +const employees = [ + { name: "Ana", sector: "Desarrollo", salary: 150000 }, + { name: "Luis", sector: "Diseño", salary: 120000 }, + { name: "Marta", sector: "Desarrollo", salary: 160000 }, + { name: "Carlos", sector: "RRHH", salary: 110000 }, + { name: "Julia", sector: "Diseño", salary: 130000 } +]; + +const tableContainer = document.getElementById('tableEmployees'); + +const table = document.createElement('table'); +const headerRow = document.createElement('tr'); + +['Nombre', 'Sector', 'Salario'].forEach(headerText => { + const th = document.createElement('th'); + th.textContent = headerText; + headerRow.appendChild(th); +}); +table.appendChild(headerRow); +tableContainer.appendChild(table); + +employees.forEach(employee => { + const row = document.createElement('tr'); + ['name', 'sector', 'salary'].forEach(key => { + const td = document.createElement('td'); + td.textContent = employee[key]; + row.appendChild(td); + }); + table.appendChild(row); +}); + +table.appendChild(document.createElement('tr')); // Fila vacía para separación + +const averageSalary = employees.reduce((sum, emp) => sum + emp.salary, 0) / employees.length; +const averageRow = document.createElement('tr'); +const averageLabelCell = document.createElement('td'); +averageLabelCell.textContent = 'Salario Promedio'; +averageRow.appendChild(averageLabelCell); +const averageValueCell = document.createElement('td'); +averageValueCell.textContent = averageSalary; +averageRow.appendChild(averageValueCell); +table.appendChild(averageRow); diff --git a/ejercicio6/index.html b/ejercicio6/index.html index ea1f061..4323639 100644 --- a/ejercicio6/index.html +++ b/ejercicio6/index.html @@ -8,7 +8,9 @@