Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 8dbda53

Browse files
committed
complete add and add2 functions
1 parent d7af184 commit 8dbda53

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

add/add.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
function add(param1: number, param2: number): number {
2-
2+
return param1 + param2;
33
}
44

5-
// function add2(param1: number[]): number {
6-
7-
// }
8-
// console.log(add(1, 2));
9-
// console.log(add(3, 2));
5+
function add2(param1: number[]): number {
6+
let sum = 0;
7+
for (let i = 0; i < arguments.length; i++){
8+
sum += arguments[i];
9+
}
10+
return sum;
11+
}
12+
console.log(add(1, 2));
13+
console.log(add(3, 2));
1014

11-
// console.log(add2(1,2,3,4,5));
12-
// console.log(add2(2,3));
15+
console.log(add2(1,2,3,4,5));
16+
console.log(add2(2,3));
1317

0 commit comments

Comments
 (0)