File tree Expand file tree Collapse file tree 5 files changed +76
-37
lines changed Expand file tree Collapse file tree 5 files changed +76
-37
lines changed Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
// const anchor = document.querySelector('a')!;
3
- // console.log(anchor.href );
4
- // Classes
5
- class Invoice {
6
- constructor ( c , d , a ) {
7
- this . client = c ;
8
- this . details = d ;
9
- this . amount = a ;
10
- }
11
- format ( ) {
12
- return ` ${ this . client } owes $ ${ this . amount } for ${ this . details } .` ;
3
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
4
+ const me = {
5
+ name : 'Shuan' ,
6
+ age : 30 ,
7
+ speak ( text ) {
8
+ console . log ( text ) ;
9
+ } ,
10
+ spend ( amount ) {
11
+ console . log ( 'I spend' , amount ) ;
12
+ return amount ;
13
13
}
14
- }
15
- const invOne = new Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
16
- const invTwo = new Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
14
+ } ;
15
+ console . log ( me ) ;
16
+ // Classes
17
+ const Invoice_1 = require ( "./classes/Invoice" ) ;
18
+ const invOne = new Invoice_1 . Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
19
+ const invTwo = new Invoice_1 . Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
17
20
let invoices = [ ] ;
18
21
invoices . push ( invOne ) ;
19
22
invoices . push ( invTwo ) ;
20
- console . log ( invoices ) ;
23
+ invoices . forEach ( inv => {
24
+ console . log ( inv . client , inv . amount , inv . format ( ) ) ;
25
+ } ) ;
21
26
// const form = document.querySelector('form')!;
22
27
const form = document . querySelector ( '.new-item-form' ) ;
23
28
// console.log(form.children);
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3
+ exports . Invoice = void 0 ;
4
+ class Invoice {
5
+ constructor ( client , details , amount ) {
6
+ this . client = client ;
7
+ this . details = details ;
8
+ this . amount = amount ;
9
+ }
10
+ format ( ) {
11
+ return `${ this . client } owes $${ this . amount } for ${ this . details } .` ;
12
+ }
13
+ }
14
+ exports . Invoice = Invoice ;
Original file line number Diff line number Diff line change @@ -43,6 +43,6 @@ <h1>Finance Logger</h1>
43
43
< a href ="https://www.thenetninja.co.uk "> The Net Ninja</ a >
44
44
</ footer >
45
45
46
- < script src ='app.js '> </ script >
46
+ < script type =" module " src ='app.js '> </ script >
47
47
</ body >
48
48
</ html >
Original file line number Diff line number Diff line change 2
2
3
3
// console.log(anchor.href);
4
4
5
- // Classes
6
- class Invoice {
7
- client : string ;
8
- details : string ;
9
- amount : number ;
10
-
11
- constructor ( c : string , d : string , a : number ) {
12
- this . client = c ;
13
- this . details = d ;
14
- this . amount = a ;
15
- }
16
-
17
- format ( ) {
18
- return `${ this . client } owes $${ this . amount } for ${ this . details } .` ;
5
+ // interfaces
6
+ interface IsPerson {
7
+ name : string ,
8
+ age : number ,
9
+ speak ( a : string ) : void ;
10
+ spend ( a : number ) : number ;
11
+ }
19
12
13
+ const me : IsPerson = {
14
+ name : 'Shuan' ,
15
+ age : 30 ,
16
+ speak ( text : string ) : void {
17
+ console . log ( text ) ;
18
+
19
+ } ,
20
+ spend ( amount : number ) :number {
21
+ console . log ( 'I spend' , amount ) ;
22
+ return amount ;
20
23
}
21
24
}
22
25
23
- const invOne = new Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
24
- const invTwo = new Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
25
-
26
- let invoices : Invoice [ ] = [ ] ;
27
- invoices . push ( invOne ) ;
28
- invoices . push ( invTwo ) ;
29
-
30
- console . log ( invoices ) ;
26
+ console . log ( me ) ;
31
27
32
28
33
29
30
+ // Classes
31
+ import { Invoice } from "./classes/Invoice" ;
34
32
33
+ const invOne = new Invoice ( 'mario' , 'work on the mario website' , 250 ) ;
34
+ const invTwo = new Invoice ( 'luigi' , 'work on the luigi website' , 300 ) ;
35
35
36
+ let invoices : Invoice [ ] = [ ] ;
36
37
38
+ invoices . push ( invOne ) ;
39
+ invoices . push ( invTwo ) ;
40
+ invoices . forEach ( inv => {
41
+ console . log ( inv . client , inv . amount , inv . format ( ) ) ;
42
+ } )
37
43
38
44
39
45
// const form = document.querySelector('form')!;
Original file line number Diff line number Diff line change
1
+ export class Invoice {
2
+
3
+
4
+ constructor (
5
+ readonly client : string ,
6
+ private details : string ,
7
+ public amount : number ,
8
+ ) { }
9
+
10
+ format ( ) {
11
+ return `${ this . client } owes $${ this . amount } for ${ this . details } .` ;
12
+
13
+ }
14
+ }
You can’t perform that action at this time.
0 commit comments