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
Function with Var Args -
function sum(...numbers) {
}console.log(sum(1, 2, 3, 4, 5)); // Output: 15
Function with 2 Parameters -
function calculateArea(length, width) {
}console.log(calculateArea(5, 10)); // Output: 50