File tree Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Expand file tree Collapse file tree 2 files changed +17
-22
lines changed Original file line number Diff line number Diff line change 2
2
// let greet: Function = () => {
3
3
// console.log('hello, world');
4
4
// }
5
- // greet = 'hello';
6
- // greet = () => {
7
- // console.log('hello, again');
8
- // }
9
- var add = function ( a , b , c /*?*/ ) {
10
- if ( c === void 0 ) { c /*?*/ = 10 ; }
11
- console . log ( a + b ) ;
12
- console . log ( c ) ;
5
+ var logDetails = function ( uid , item ) {
6
+ console . log ( "" . concat ( item , " has a uid of " ) . concat ( uid ) ) ;
7
+ } ;
8
+ var greet = function ( user ) {
9
+ console . log ( "" . concat ( user . name , " says hello" ) ) ;
13
10
} ;
14
- add ( 5 , 10 , 'ninja' ) ;
15
- var minus = function ( a , b ) {
16
- return a + b ;
11
+ var greetAgain = function ( user ) {
12
+ console . log ( "" . concat ( user . name , " says hello again" ) ) ;
17
13
} ;
18
- var result = minus ( 10 , 7 ) ;
19
- console . log ( result ) ;
Original file line number Diff line number Diff line change 8
8
// console.log('hello, again');
9
9
// }
10
10
11
- const add = ( a : number , b : number , c /*?*/ : number | string = 10 ) : void => {
12
- console . log ( a + b ) ;
13
- console . log ( c ) ;
14
- }
11
+ type StringOrNum = string | number ;
12
+ type objWithName = { name : string , uid : StringOrNum } ;
15
13
16
- add ( 5 , 10 , 'ninja' ) ;
14
+ const logDetails = ( uid : StringOrNum , item : String ) => {
15
+ console . log ( `${ item } has a uid of ${ uid } ` ) ;
16
+ }
17
17
18
- const minus = ( a : number , b : number ) : number => {
19
- return a + b ;
18
+ const greet = ( user : objWithName ) => {
19
+ console . log ( ` ${ user . name } says hello` ) ;
20
20
}
21
21
22
- let result = minus ( 10 , 7 ) ;
23
- console . log ( result ) ;
22
+ const greetAgain = ( user : objWithName ) => {
23
+ console . log ( `${ user . name } says hello again` ) ;
24
+ }
You can’t perform that action at this time.
0 commit comments