Hi Everyone,

I'm just learning JavaScript through a Lynda.com tutorial, and I'm trying to push myself beyond some of the examples in each chapter.

Right now I'm on arrays. One of the examples they went through was adding all of the values in the array:

Code:
var myArray = [500, 500, 500, 500, 500];

var total = 0;

for ( var i = 0; i < myArray.length; i++ ) {
	total = total + myArray[i];
}

document.write("The total is: " + total);
Okay so I understand this. My challenge, which I can't seem to solve by myself, is this: What if I had an array with 6 values, and I wanted to add the first two numbers, then subtract the third? And loop through this each time.

For example:

Code:
var myArray = [35, 250, 75, 60, 90, 100];
My desired output would be:

210 (result from 35 + 250 - 75)
260 (result from 210 + 60 + 90 - 100)

What are some ways I could accomplish this?

Thank you!

John