Howdy, Stranger!

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

Categories

javescript help needed please help!!!!!

kelly123kelly123 Member Posts: 2
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




//Write your functions here.
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]

Comments

  • newuser79newuser79 Member Posts: 1
    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.
  • kelly123kelly123 Member Posts: 2
    oi dickwad

    how am i asking for someone to do it for me ?
    as you can plainly see i have done it already and and not once have i asked for someone to do it for me.
    so unless you have something constructive to say would you please stay out of my business.
    thank you
    kelly
Sign In or Register to comment.