Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how sum all array element with for

// define a list
const list = [1,2,3,4,5];

// create a function return result of sum of elements
const result = () => {
  let sum = 0;
  for (let i = 0; i < list.length; i++) {
    sum += list[i];
  }
  return sum
}
console.log(result());
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #array #element
ADD COMMENT
Topic
Name
7+7 =