the sum function is designed to take any number of arguments, add them together, and return the sum. This is achieved by using the rest parameter to collect the input numbers as an array, then iterating through the array and accumulating their values to calculate the total sum.
let a = 1;
let b = 2;
let c = 3;
let d = 4;
let e = 5;
console.log(sum(a, b, c, d, e));
function sum(...numbers) {
let total = 0;
for (let number of numbers) {
total += number;
}
return total;
}