Javascript...вычисление суммы целых чисел...передача функций с использованием массивов
I'm appealing for an assistance in developing JavaScript program that asks a user to input integers(say 10 integers) , store them in an array called nums(array of 10 integers), then pass this array to a function called add which adds all the array values and returns the correct answer. My attempts have bore no fruits...I trust someone will help me out. If there are other easier approaches, I shall very much appreciate. Thank you!
Что я уже пробовал:
<html> <head> <script> function Add(d){// array reference received var j,sum; sum=0; for(j=0;j<10;j++){ sum=sum+parselnt(d[j]); } return sum } </script> </head> <body bgcolor="aqua"> <script> var num=new Array(10); var i; for(i=0;i<10;i++){ num[i]=prompt("Enter value at "+i); } alert("The sum of the ten numbers is "+Add(num));//call and pass array name </script> </body> </html>