Skip to content

Instantly share code, notes, and snippets.

@dg92
Created May 13, 2018 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dg92/d18524d0b0aec2d0ab23c26b263a96bc to your computer and use it in GitHub Desktop.
Save dg92/d18524d0b0aec2d0ab23c26b263a96bc to your computer and use it in GitHub Desktop.
// to calculate the sum of array elements
const sum = (arr) => {
let result = 0;
for (let i = 0; i < arr.length; i++) {
result += arr[i];
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment