Created
November 21, 2016 04:11
-
-
Save sohana08/56e61ead59a797b2f9e7c44881698499 to your computer and use it in GitHub Desktop.
can anyone help me with the following,how to pass an array as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<DOCTYPE! html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var myarr=[1,2,3,4,5]; | |
function sum(arr) { | |
var sum1=0; | |
var length=myarr.length; | |
for (var i= 0;i < length;i++){ | |
sum1+=myarr[i]; | |
return sum1; | |
} | |
} | |
sum(myarr); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment