let numbers = [10,20,30,40,50];
let sum = 0;
for(let i =0; i< numbers.length; i++) {
sum += numbers[i];
}
console.log(sum);
// Output : 150
const sumNums = (arr)=>{
let sum=0;
for (let t = 0; t < arr.length; t++) {
if(typeof arr[t] == "number" ){
sum = sum + arr[t] ;
}
}
return sum;
}
//if you find this answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
const sum = [1, 2, 3].reduce((partialSum, a) => partialSum + a, 0);
console.log(sum); // 6