📅  最后修改于: 2022-03-11 15:03:27.583000             🧑  作者: Mango
// 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());