Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sum of array elements in javascript

let arr = [2, 4, 1, 3, 5];
let result = 0;

for (let i = 0; i < arr.length; i++) {
   result += arr[i];
}

console.log(result); // 15
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #array #elements #javascript
ADD COMMENT
Topic
Name
6+1 =