const arr = [1, 2, 3, 4];
const sum = arr.reduce((a, b) => a + b, 0);
// sum = 10
const summation = (n) => (n * (n + 1)) / 2;
const array = [1, 2, 3];
const result = array.reduce((accumulator, current) => accumulator + current, 0);
// result === 1 + 2 + 3;
let sum = (...para) => para.reduce((d,b) => d + b);
const summation = n => n * (n + 1) / 2;