-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
39 lines (29 loc) · 1.46 KB
/
main.ts
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
29
30
31
32
33
34
35
36
37
38
39
import { serie } from './serie'; // Asegurémonos de importar Serie para tener su tipo
import { series } from './data';
import { promedio_series } from './data';
window.onload = () => {
populateTable();
};
function populateTable(): void {
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: serie) => {
const row: HTMLTableRowElement = document.createElement('tr');
const idCell: HTMLTableCellElement = document.createElement('td');
idCell.textContent = serie.id.toString();
const nameCell: HTMLTableCellElement = document.createElement('td');
nameCell.textContent = serie.title;
const channelCell: HTMLTableCellElement = document.createElement('td');
channelCell.textContent = serie.channel;
const seasonsCell: HTMLTableCellElement = document.createElement('td');
seasonsCell.textContent = serie.seasons.toString();
row.append(idCell, nameCell, channelCell, seasonsCell);
tableBody.appendChild(row);
});
}
var promedioSeries = document.getElementsByClassName("promedio_series")[0] as HTMLParagraphElement;
promedioSeries.textContent = `Seasons average: ${promedio_series}`;
}