Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript unknown number of parameters

function add (...numbers) {
  let sum = 0;
  for (let i = 0; i < numbers.length; i++) {
    sum += numbers[i]
  };
  console.log(sum);
};

add(2, 3);
add(5, 3, 7, 2);
 
PREVIOUS NEXT
Tagged: #javascript #unknown #number #parameters
ADD COMMENT
Topic
Name
4+3 =