A rest parameter gathers many arguments into an array. Type the rest parameter as number[] and return a number. Decide what to return when there are no inputs.
Keep the function pure and the code short.
function sum(...xs: number[]) {
return xs.reduce((a, b) => a + b, 0);
}
Compute the average of any number of inputs.