I need to add to this subtraction tamaño -= parseInt(distanciaCentroUltimo[n]);
the last element of otroArray
that is 970 and divide it by 2
NOTE : the array that is named anotherArray can grow so that 970 will not always be the last element.
Let me explain: this subtraction tamaño -= parseInt(distanciaCentroUltimo[n])
gives me a result of tamaño = 895
, then at that 895
I must subtract it with the last value of otrosarray
and divide it by 2
the cell must give me a final result of 410
size.
The mathematical operation would be like this: 4500-890-930-885-900 = 895 - 970 /2 = 410
This is what I have at the moment.
var distanciaCentroUltimo = [890,930,885,900];
var tamaño = 4500;
var otroArray = [920,850,970];
for ( n in distanciaCentroUltimo) {
tamaño -= parseInt(distanciaCentroUltimo[n]);
};
console.log(tamaño);