I have a dynamically sized array that looks something like this:

```
var myArray = [0.10,0.12,0.08,0.08];

```

The array can have more or less values than above.

The aim here is to plug them into the following formula:

```
var iFormula = 1 - ((1 - value1)*(1 - value2)*(1 - value3)* ... (1 - valuen))

```

I tried the following for loop:

```
for(var i = 0; i < myArray .length; i++) {

    iResult = iResult * (1 - myArray[i])
};

```

Then subtracted iResult from 1 but as you can imagine, doing the above for loop is not the same as calculating iFormula. For example, using the array at the top of my question, if I combine the two 0.08 values together to make the following array:

```
var myArray = [0.10,0.12,0.16];

```

The two following equations use the same effective numbers but produce two different results:

```
var iResult_1 = 1 - ((1 - 0.10)*(1 - 0.12)*(1 - 0.08)*(1 - 0.08)); // 0.3297
var iResult_2 = 1 - ((1 - 0.10)*(1 - 0.12)*(1 - 0.16));            // 0.3347

```

As the array is dynamically sized, I don't know how many values will be in the array when it reaches a certain part of my code. Therefore, I can't hardcode the formula to be something like:

```
var iFormula = 1 - ((1 - myArray[0])*(1 - myArray[1])*(1 - myArray[2])

```

Any ideas how I can construct this? Is there a much better way of doing this sort of thing?