subtract values from an array and add another value [closed]

-5

I have this array:

var distanciaCentroUltimo = [790,850];
var tamaño = 2455;

by means of a for, how do I make the following?

  

2455-790-850 = 815

    
asked by Eduard Zora 21.04.2017 в 22:59
source

1 answer

0

Example of how to sequentially read a array through a for :

var distanciaCentroUltimo = [790,850];
var tamaño = 2455;

for ( n in distanciaCentroUltimo) {
    tamaño -= parseInt(distanciaCentroUltimo[n]);
};

console.log(tamaño);

The result is 815 and not 4100

    
answered by 21.04.2017 / 23:45
source