views:

184

answers:

2

Thanks for the help guys

A: 

You should index createArray the same way you already do with numberArray[c].

Péter Török
Thanks I will give it a go.
newuser
+1  A: 

your implementation of function "calculateDifferences" is not correct.
this function should look like this:

function calculateDifferences()
{
var createArray = new Array (numberArray.length);
for (var c = 0; c < numberArray.length - 1 ; c = c + 1) {
/*
because of the function "difference" has two parameters (firstNumber, secondNumber) in its declaration, we should give two arguments. (that are adjacent elements in array)
*/
createArray[c] = difference(numberArray[c],numberArray[c+1]); }
/ *
calculating difference of first and last element of array and assign it to returning array's last element.
*/
createArray[numberArray.length - 1] = difference(numberArray[0],numberArray[numberArray.length - 1]);
return createArray;
}

Zango
Thank you so much for explaining that to me. I've had no idea where I have been going wrong but the way you have explained it now makes sense to me. I take it the -1 is to tell it to loop until the end of the array?
newuser