File tree Expand file tree Collapse file tree 3 files changed +47
-26
lines changed Expand file tree Collapse file tree 3 files changed +47
-26
lines changed Original file line number Diff line number Diff line change 1
- import { Invoice } from './classes/Invoice.js' ;
2
- const invOne = new Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
3
- const invTwo = new Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
4
- // invOne.client = 'yoshi';
5
- // invOne.amount = 50;
6
- let invoices = [ ] ;
7
- invoices . push ( invOne ) ;
8
- invoices . push ( invTwo ) ;
9
- invoices . forEach ( inv => {
10
- console . log ( inv . client , /*inv.details,*/ inv . amount , inv . format ( ) ) ;
11
- } ) ;
1
+ const me = {
2
+ name : 'shaun' ,
3
+ //age: 30,
4
+ speak ( text ) {
5
+ console . log ( text ) ;
6
+ } ,
7
+ spend ( amount ) {
8
+ console . log ( 'I spent ' , amount ) ;
9
+ return amount ;
10
+ } ,
11
+ } ;
12
+ console . log ( me ) ;
13
+ me . speak ( 'hello, world' ) ;
14
+ const greetPerson = ( person ) => {
15
+ console . log ( 'hello ' , person . name ) ;
16
+ } ;
17
+ greetPerson ( me ) ;
18
+ //greetPerson({name: 'shaun'});
12
19
const form = document . querySelector ( '.new-item-form' ) ;
13
20
console . log ( form . children ) ;
14
21
// inputs
Original file line number Diff line number Diff line change 1
1
import { Invoice } from './classes/Invoice.js' ;
2
2
3
- const invOne = new Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
4
- const invTwo = new Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
5
-
6
- // invOne.client = 'yoshi';
7
- // invOne.amount = 50;
8
-
9
- let invoices : Invoice [ ] = [ ] ;
10
- invoices . push ( invOne )
11
- invoices . push ( invTwo ) ;
12
-
13
- invoices . forEach ( inv => {
14
- console . log ( inv . client , /*inv.details,*/ inv . amount , inv . format ( ) ) ;
15
- } )
16
-
17
-
3
+ // interfaces
4
+ export interface IsPerson {
5
+ name : string ;
6
+ age ?: number ;
7
+ speak ( a : string ) : void ;
8
+ spend ( a : number ) : number ;
9
+ }
10
+
11
+ const me : IsPerson = {
12
+ name : 'shaun' ,
13
+ //age: 30,
14
+ speak ( text : string ) : void {
15
+ console . log ( text ) ;
16
+ } ,
17
+ spend ( amount : number ) : number {
18
+ console . log ( 'I spent ' , amount ) ;
19
+ return amount ;
20
+ } ,
21
+ } ;
22
+
23
+ console . log ( me ) ;
24
+ me . speak ( 'hello, world' ) ;
25
+
26
+ const greetPerson = ( person : IsPerson ) : void => {
27
+ console . log ( 'hello ' , person . name ) ;
28
+ }
29
+
30
+ greetPerson ( me ) ;
31
+ //greetPerson({name: 'shaun'});
18
32
19
33
const form = document . querySelector ( '.new-item-form' ) as HTMLFormElement ;
20
34
console . log ( form . children ) ;
You can’t perform that action at this time.
0 commit comments