Answers for "how to find the sum of an array js"

26

array sum javascript

const arr = [1, 2, 3, 4];
const sum = arr.reduce((a, b) => a + b, 0);
// sum = 10
Posted by: Guest on January-26-2021
0

how to find sum of array

//C++
int arr[5]={1,2,3,4,5};
int sum=0;
for(int i=0; i<5; i++){sum+=arr[i];}
cout<<sum;
Posted by: Guest on May-29-2020

Code answers related to "how to find the sum of an array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language