Skip to content

Instantly share code, notes, and snippets.

@RachelSa
Created July 7, 2016 23:11
Show Gist options
  • Save RachelSa/cdca9cdb3dbd03cfc77435a35dd6449d to your computer and use it in GitHub Desktop.
Save RachelSa/cdca9cdb3dbd03cfc77435a35dd6449d to your computer and use it in GitHub Desktop.
adds elements in array
function add(arr){
sum = 0
arr.forEach(function(num){
sum += num;
}); console.log(sum);
}
add([1,2,3,4,5])
add([-1,0,2])
add([3,3,3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment