I have two arrays. The first is array_impuestos which is the tax names. The second is array_impuestos_valor which contains the corresponding tax values. The tax value for the tax name at index 0 of array_impuestos would be the value at index 0 of array_impuestos_valor.
I need to detect which elements are repeated in array_impuestos and sum the corresponding values in array_impuestos_valor.
For example, 'iva.21%' appears twice in array_impuestos corresponding to both '21' and '10.5' in array_impuesto_valor.
I need to sum those last 2 values.
array_impuestos = ["iva.21%", "irfp.-7%", "iva.21%"];
array_impuestos_valor = ["21", "3.5", "10.5"];
array_impuestos.forEach(function (elemento1, indice1, array1) {
nombre1 = elemento1;
indice1 = indice1;
array_impuestos_valor.forEach(function (elemento2, indice2, array2) {
if (indice1 == indice2) {
impuesto_repetido = (array_impuestos.indexOf(elemento1) === indice1);
if (impuesto_repetido == false) {
//I don't know how to continue sincerely
console.log(nombre1 + ' ' + elemento2);
}
}
});
});