Skip to content

Instantly share code, notes, and snippets.

@sohana08
Created November 21, 2016 04:11
Show Gist options
  • Save sohana08/56e61ead59a797b2f9e7c44881698499 to your computer and use it in GitHub Desktop.
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
<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