4 ms·
Are you talking about the var argument functions or the function which takes definite parameters? Function with Var Args - function sum(...numbers) { retur
by chetan_187 2y ago
Are you talking about the var argument functions or the function which takes definite parameters?
Function with Var Args -
function sum(...numbers) {
return numbers.reduce((total, number) => total + number, 0);
}
console.log(sum(1, 2, 3, 4, 5)); // Output: 15
Function with 2 Parameters -
function calculateArea(length, width) {
return length * width;
}
console.log(calculateArea(5, 10)); // Output: 50