Funkcja zmienna w JavaScript

//Sum of variable number of Arguments
function sum() {
    let x = 0;

  // loop performs on number of arguments e.g. sum(1,2,3) i.e. three times
    for (let i = 0; i < arguments.length; ++i)
        // loop performs below equation 
  		// x += arguments[0]; x += arguments[1]; x += arguments[2]; 
        x += arguments[i];

    return x;
}

sum(1, 2); // returns 3
sum(1, 2, 3); // returns 6
sum(1, 2, 3, 4); // returns 10

Ali Salman