Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions exercises/08.3-Sum-all-items/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## :pencil: Instructions:

Using a `for` loop, complete the code of the function `sum` so that it returns the sum of all the items in a given array, for example:
Using a `for` loop, complete the code of the function `sumTheElements` so that it returns the sum of all the items in a given array, for example:

```js
console.log(sumTheElements([2,13,34,5]))
Expand All @@ -11,14 +11,16 @@ console.log(sumTheElements([2,13,34,5]))

### Expected result:

925960
`925960`

# :bulb: Hint:

+ Initilize a variable `total` at 0.

+ Loop the entire array.
+ Call the function with any array of numbers that add up to the expected result above.

+ Loop the entire array inside of the function.

+ On every loop add the value of each item into the `total` variable.

+ Return the `total` variable (outside of the loop but inside of the function).
+ Return the `total` variable (outside of the loop but inside of the function).