****Hi there everyone. I am new to java Script. Just finished functions. I was trying to calculate the sum of an array values. So in this case the desired output would have been 21 but whenever i log on console i keep getting the value 1 . Can someone help****
{
let array = [1,2,3,4,5,6] ;
let sum = 0 ;
function array_sum (){
for (let i = 0 ; i < array.length ; i++){
sum = sum + array[i] ;
return sum;
}
}
console.log(array_sum());