1function sum(...values) {
2 console.log(values);
3}
4sum(1);
5sum(1, 2);
6sum(1, 2, 3);
7sum(1, 2, 3, 4);
8
9
10function sum(...values) {
11 let sum = 0;
12 for (let i = 0; i < values.length; i++) {
13 sum += values[i];
14 }
15
16 return sum;
17}
18console.log(sum(1)); //1
19console.log(sum(1, 2)); //3
20console.log(sum(1, 2, 3)); // 5
21console.log(sum(1, 2, 3, 4)); //10
1function functionName(parameter1, parameter2, parameter3) {
2 // code to be executed
3}