Skip to content

Commit f8f6964

Browse files
committed
lesson-12
1 parent 3bfe8ad commit f8f6964

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

public/app.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
"use strict";
2-
var anchor = document.querySelector('a');
3-
if (anchor) {
4-
console.log(anchor.href);
5-
}
6-
console.log(anchor.href);
7-
//const form = document.querySelector('form')!;
2+
// classes
3+
var Invoice = /** @class */ (function () {
4+
function Invoice(c, d, a) {
5+
this.client = c;
6+
this.details = d;
7+
this.amount = a;
8+
}
9+
Invoice.prototype.format = function () {
10+
return this.client + " owes \u00A3" + this.amount + " for " + this.details;
11+
};
12+
return Invoice;
13+
}());
14+
var invOne = new Invoice('mario', 'work on the mario website', 250);
15+
var invTwo = new Invoice('luigi', 'work on the luigi website', 300);
16+
var invoices = [];
17+
invoices.push(invOne);
18+
invoices.push(invTwo);
19+
// invoices.push({ name: 'shaun' });
20+
console.log(invoices);
821
var form = document.querySelector('.new-item-form');
922
console.log(form.children);
1023
// inputs

src/app.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1-
const anchor = document.querySelector('a')!;
2-
if(anchor) {
3-
console.log(anchor.href);
1+
// classes
2+
class Invoice {
3+
client: string;
4+
details: string;
5+
amount: number;
6+
7+
constructor(c: string, d: string, a: number){
8+
this.client = c;
9+
this.details = d;
10+
this.amount = a;
11+
}
12+
13+
format() {
14+
return `${this.client} owes £${this.amount} for ${this.details}`;
15+
}
416
}
5-
console.log(anchor.href);
617

7-
//const form = document.querySelector('form')!;
18+
const invOne = new Invoice('mario', 'work on the mario website', 250);
19+
const invTwo = new Invoice('luigi', 'work on the luigi website', 300);
20+
21+
let invoices: Invoice[] = [];
22+
invoices.push(invOne)
23+
invoices.push(invTwo);
24+
// invoices.push({ name: 'shaun' });
25+
26+
console.log(invoices);
27+
28+
829
const form = document.querySelector('.new-item-form') as HTMLFormElement;
930
console.log(form.children);
1031

0 commit comments

Comments
 (0)