I need to perform the following operation.
Example, I have an array cantidad = [420, 940, 920, 850,970];
and% ancho = 4500
.
The formula works like this:
420 + 940 / 2 = 890;
940 / 2 + 920 / 2 = 930;
920 /2 + 850 /2 = 885;
850 / 2 + 970 /2 = 910;
4500-890-930-885-910 = 885;
4500-890-930-885-910 = 885 -970/2 = 400;
How do I do it in JavaScript?