Using spread operator in function parameter
Easy
11
79.5% Acceptance
In this lab, you will create a JavaScript function called sum
that uses the spread operator when defining the paramemter args
to accept any number of arguments and calculates their sum. The function should be exported for testing purposes.
JavaScript's spread operator (...
) allows you to expand iterable elements like arrays or strings. It's useful when you want to collect any number of arguments passed to a function or when you want to spread elements among different arrays or objects.