1function addition(...nombre) {
2
3 let resultat = 0
4
5 nombre.forEach(nombre => {
6 resultat+= nombre ;
7 });
8
9 console.log(resultat) ;
10
11}
12
13addition(4 ,9 ,5 ,415 ,78 , 54) ;
1function extractingArgs(...args){
2 return args[1];
3}
4
5// extractingArgs(8,9,1); // Returns 9
6
7function addAllArgs(...args){
8 let sumOfArgs = 0;
9 let i = 0;
10 while(i < args.length){
11 sumOfArgs += args[i];
12 i++;
13 }
14 return sumOfArgs;
15}
16
17addAllArgs(6, 5, 7, 99); // Returns 117
18addAllArgs(1, 3, 4); // Returns 8
19
1function multiply(multiplier, ...theArgs) {
2 return theArgs.map(element => {
3 return multiplier * element
4 })
5}
6
7let arr = multiply(2, 1, 2, 3)
8console.log(arr) // [2, 4, 6]
9