Answers for "two parameter function javascript"

4

javascript function multiple parameters

function sum(...values) {
    console.log(values);
}
sum(1);
sum(1, 2);
sum(1, 2, 3);
sum(1, 2, 3, 4);


function sum(...values) {
    let sum = 0;
    for (let i = 0; i < values.length; i++) {
        sum += values[i];
    }
  
    return sum;
}
console.log(sum(1)); //1
console.log(sum(1, 2)); //3
console.log(sum(1, 2, 3)); // 5
console.log(sum(1, 2, 3, 4)); //10
Posted by: Guest on July-10-2020
1

two parameter function javascript

function functionName(parameter1, parameter2, parameter3) {
  // code to be executed
}
Posted by: Guest on August-06-2021

Code answers related to "two parameter function javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language