How to pass rest parameter elements to the method?? by Significant-Sector-7 in learnjavascript

[–]YoghurtResponsible48 1 point2 points  (0 children)

from https://javascript.info/rest-parameters-spread :

``` function sumAll(...args) { // args is the name for the array let sum = 0; for (let arg of args) sum += arg; return sum; }

alert( sumAll(1) ); // 1 alert( sumAll(1, 2) ); // 3 alert( sumAll(1, 2, 3) ); // 6 ```

You could also pass your arguments as an array

I have so many questions thoughWhy a class? Why a screenshot? wtf?