JavaScript mengambil sejumlah argumen

function sum() {
  // "arguments" is an object that can be converted to an Array
  const args = Array.from(arguments);
  return args.reduce((acc, next) => acc + next);
}

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