// 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());