Skip to content

Commit 3f9ee89

Browse files
Merge pull request #21 from yashksaini-coder/backup
Activity 4 completed for Day-8 Co-authored-by: Garv Saini <garvkumarsaini@gmail.com>
2 parents fbe29e6 + d695325 commit 3f9ee89

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Day8/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ arr2 = [4, 5, 6];
4646
newarr = [...arr1, ...arr2];
4747
console.log(`New Array: ${newarr}`);
4848

49-
// Use the rest operator in a function to accept an arbitrary number of arguments, sum them, and return the result.
49+
// Task 6: Use the rest operator in a function to accept an arbitrary number of arguments, sum them, and return the result.
5050

5151
function sum(...theArgs) {
5252
let total = 0;
@@ -57,3 +57,16 @@ function sum(...theArgs) {
5757
}
5858

5959
console.log(`Sum of 1, 2, 3, 4, 5: ${sum(1, 2, 3, 4, 5)}`);
60+
61+
62+
console.log("-------------------------------------------------");
63+
console.log("Activity 4: ");
64+
65+
66+
// Task 7: Write a function that takes two parameters and returns their product, with the second parameter having a default value of 1. Log the result of calling this function with and without the second parameter.
67+
68+
function product(a, b = 1) {
69+
return a * b;
70+
}
71+
72+
console.log(`Product of 5 and 2: ${product(5, 2)}`);

0 commit comments

Comments
 (0)