Skip to content
← Back to Community
Sum Them All
Profile icon
Carderalli

Calcule the sum of an array off integers. For example, if numbers = [3, 13, 4, 11, 9], the sum is 40.

Function Description
Complete the function arraySum in the editor below. The function must return the integer sum of the numbers array.
arraySum has the following parameter(s):
number[numbers[0]], ...numbers[n-1]]: an array of integers

Constraints
. 1 <= n <= 10^4
. 1 <= numbers[i] < = 10^4

Input from stdin will be processed as follows and passed to the function.

The first line contains an integer n, the size of the array numbers.
Each of the next n lines contains an integer numbers[i] where 0 <= i<= n.

Voters
Profile icon
Carderalli
Comments
hotnewtop
Profile icon
theangryepicbanana

Please stop posting your homework here. Try to post stuff your proud of rather than everything you do :)

Profile icon
AdCharity
Profile icon
theangryepicbanana

@AdCharity oh I misunderstood lol. looked like it was in the share section

Profile icon
AdCharity

@theangryepicbanana actually I didn't notice I just said lmao cause I always do that lmao

Profile icon
AdCharity

Ohhh okay just a thought. I think if you created a global variable, looped through the object/array using for...in and then take the global variable and add it to the next value of the array it will most likely work :D

Profile icon
MrEconomical

isnt there a built in function for this...

Profile icon
Vandesm14

What have you tried so far?