Skip to content

Instantly share code, notes, and snippets.

@JohnMGant
Last active August 7, 2020 17:35
Show Gist options
  • Select an option

  • Save JohnMGant/e68c17e777b425be9a3eb500d900f75c to your computer and use it in GitHub Desktop.

Select an option

Save JohnMGant/e68c17e777b425be9a3eb500d900f75c to your computer and use it in GitHub Desktop.
Adding an array of numbers in JavaScript using for loop
function Add(values) {
let sum = 0
const length = values.length
for (var i = 0; i < length; i++) {
sum += values[i]
}
return sum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment