Skip to content

Commit e23b4f6

Browse files
committed
lesson-15
1 parent df98b12 commit e23b4f6

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

public/app.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
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'});
1219
const form = document.querySelector('.new-item-form');
1320
console.log(form.children);
1421
// inputs

public/interfaces/HasFormatter.js

Whitespace-only changes.

src/app.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
import { Invoice } from './classes/Invoice.js';
22

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'});
1832

1933
const form = document.querySelector('.new-item-form') as HTMLFormElement;
2034
console.log(form.children);

0 commit comments

Comments
 (0)