-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreeter.ts
41 lines (36 loc) · 857 Bytes
/
greeter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// enum Gender {
// Man,
// Woman
// }
// interface person {
// age: number,
// gender: Gender
// }
// function marry(a: person, b: person): [person, person] {
// if(a.gender!==b.gender) {
// return [a,b]
// } else {
// throw new Error('不能结婚')
// }
// }
// var c = marry({gender: Gender.Man, age: 28}, {gender: Gender.Woman, age: 18})
// console.log(c)
// function sorted(a: number[]):number[] {
// return a.sort((a, b) => b - a)
// }
// console.log(sorted([1,23,2,42,21]))
// function add(a: string, b: string): string
// function add(a: number, b: number): number
// function add(a: any, b: any): any {
// return a + b
// }
// console.log(add(1, 2))
// function min(a: number, b: number): number {
// if (a < b) {
// return ;
// } else {
// return b;
// }
// }
// var c = min(1, 2);
// console.log(c);