(...rest: any[])
| 40 | function add8(...rest: number[]): number |
| 41 | function add8(...rest: string[]): string |
| 42 | function add8(...rest: any[]): any { |
| 43 | let first = rest[0]; |
| 44 | if(typeof first === 'string'){ |
| 45 | return rest.join('') |
| 46 | } |
| 47 | if(typeof first === 'number'){ |
| 48 | return rest.reduce((pre,cur)=> pre + cur) |
| 49 | } |
| 50 | } |
| 51 | console.log(add8(1,2,3)) |
| 52 | console.log(add8('a','b', 'c')) |