-
Notifications
You must be signed in to change notification settings - Fork 0
/
household-income.js
44 lines (31 loc) · 1.39 KB
/
household-income.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*TAREA:
Crear una interfaz que permita agregar ó quitar (botones agregar y quitar) inputs+labels para completar el
salario anual de cada integrante de la familia que trabaje.
Al hacer click en "calcular", mostrar en un elemento pre-existente el mayor salario anual, menor salario anual,
salario anual promedio y salario mensual promedio.
Punto bonus: si hay inputs vacíos, ignorarlos en el cálculo (no contarlos como 0).
*/
const $addRowsButton = document.getElementById('add-rows-button')
const $removeRowsButton = document.getElementById('remove-rows-button')
const $rowsManipulation = document.getElementById('add-rows');
let i = 2;
$addRowsButton.onclick = function () {
const numberOfMembers = 1;
createMembers(numberOfMembers);
return false;
}
$removeRowsButton.onclick = function () {
removeDinamicallyAddedRows();
return false;
}
const $calculateButton = document.getElementById('calculate-button')
$calculateButton.onclick = function() {
let annualSalaries = HTMLCollectionIntoArray(document.getElementsByClassName('salary'));
const highest = getHighestAnnualSalary(annualSalaries);
const lowest = getLowestAnnualSalary(annualSalaries);
const average = getAverage(annualSalaries);
const monthlyAverage = getMonthlyAverage(annualSalaries);
showResults (highest, lowest, average, monthlyAverage);
clearDataForNewCalculation();
return false;
}