#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Posts: 2Member
Hi

Can anyone help me with this javascript please
as you can see i have given it a far shot but just not getting the end result.
but i need it to list the outcome each time i click enter in a window like this

[CODE]
16,14,4,5
2,10,1,11
8,9,10,9
1,1,1,1
0,0,0,0
Iterations taken: 4
[/CODE]

any help would be great as i am getting tired now after a week of trying

thank you

[CODE]

Ducci's Game

difference();
function difference() {

//Main program.
//Array which holds the numbers at the four corners of the square.
var numberArray = [16,14,4,5];//Edit this line to change the starting numbers
document.write(numberArray +'
');//Write out array.

//Write the rest of the main program here.
var numberArray = [16,14,4,5];
var diffArray = new Array(4);
var count = 0;
var numLen = numberArray.length;
for (count = 0; count < numLen; count++) {
if ((count + 1) == numLen) {
diffArray[count] = numberArray[count] - numberArray[0];
alert("a " +numberArray[count] + " - " + numberArray[0] + " = " + diffArray[count]);
} else {
diffArray[count] = numberArray[count] - numberArray[count + 1];
alert("b " + numberArray[count] + " - " + numberArray[count + 1] + " = " + diffArray[count]);
}
}
}

[/CODE]

· ·

• Posts: 1Member
I'm doing the M150 course for the open uni and this IS on the TMA that we are doing at the moment. The cut off date for it is March 2nd so people still have time in which to hand it in to be marked. Its the same variables, same date, same names on the arrays, same comments etc. The only good thing is the people that have done the code so far have used codes that we have not yet been introduced to and it clearly states in the TMA that we are only allowed to use the code in the books.

I'm stuck myself but that doesn't mean that I want people to do it for me. I'm just looking for a better idea on how arrays work in a loop. I just find it very dissapointing that people would come on here to get others to do their work for them when other people have to work for their degree.
· ·
• Posts: 2Member