Find summation of an array

Problem:

Suppose, you have an array like this myArray=[2,3,4,5,6,7,8,9]
You need to find summation of this array.

Solution:


let sum = 0;
let myArray = [10, 20, 30, 40, 40, 50, 60, 70, 80, 90];
for (let i = 0; i < myArray.length; i++) {
  sum = sum + myArray[i];
}
console.log("Sum of this array: " + sum);

 

About Author

Photo

Hi, I am Mahbub Hasan
Software Engineer

I am very much interested to share my programming
and development knowledge with the people.I will try
to update my blog everyday with new technology inshallah.

Thank You

For Visiting My Blog.

Contact Me