-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
28 lines (28 loc) · 1.18 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { series } from './data.js';
import { promedio_series } from './data.js';
window.onload = () => {
populateTable();
};
function populateTable() {
const tableBody = document.querySelector('tbody');
if (tableBody) {
// Limpiamos el contenido existente
tableBody.innerHTML = '';
//iteramos sobre cada serie en las series capturadas en data.ts
series.forEach((serie) => {
const row = document.createElement('tr');
const idCell = document.createElement('td');
idCell.textContent = serie.id.toString();
const nameCell = document.createElement('td');
nameCell.textContent = serie.title;
const channelCell = document.createElement('td');
channelCell.textContent = serie.channel;
const seasonsCell = document.createElement('td');
seasonsCell.textContent = serie.seasons.toString();
row.append(idCell, nameCell, channelCell, seasonsCell);
tableBody.appendChild(row);
});
}
var promedioSeries = document.getElementsByClassName("promedio_series")[0];
promedioSeries.textContent = `Seasons average: ${promedio_series}`;
}