Hello, I have an assignment for school and I cannot figure out how to do it right. I am converting an algorithm into javascript. I am supposed to have a list of numbers, but I can only figure out how to do 1 number. This is my assignment, and below that is the code I have written. PLEASE HELP!!

Assignment:

Convert the following algorithm into JavaScript code within your HTML document. Your final web page should display the algorithm title, the input and the output.

Input:

Integerlist[10];

OTHER VARIABLES:

Integer sum;

Integer i;

INITIALIZATION:

FOR i = 0 to 9 DO

list[i] = random integer between 0 and 100;

ENDIF

sum = 0;

COMPUTATION:

FOR i = 0 to 9 DO

sum = sum + list[i];

ENDDO

OUTPUT:

return(sum);

And the code i wrote is:

<html>

<head>

<title>Sum()

</title>

</head>

<body>

<h1>Sum()</h1> <br><br>

<script language="JavaScript">

var list;

var sum;

var i;

i= [1, 2, 3, 4, 5, 6, 7, 8, 9]

list = Math.round(100 * Math.random())

for (i = 0; i < 10; i++)

{

list = Math.round(100 * Math.random())

}

sum = 0

for (i = 0; i < 10; i++)

{

sum = sum + list

}

document.write("the list is=" + list + "<br />")

document.write("the sum is=" + sum)

</script>

</body>

</html>

what am I doing wrong?

Thanks SO much!!!

Tweet This+ 1 thisPost To Linkedin