Last active
August 7, 2020 17:35
-
-
Save JohnMGant/e68c17e777b425be9a3eb500d900f75c to your computer and use it in GitHub Desktop.
Adding an array of numbers in JavaScript using for loop
This file contains hidden or 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
| 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