Skip to content

Commit 97a7583

Browse files
committed
lesson-13
1 parent f8f6964 commit 97a7583

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

public/app.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"use strict";
22
// classes
33
var Invoice = /** @class */ (function () {
4-
function Invoice(c, d, a) {
5-
this.client = c;
6-
this.details = d;
7-
this.amount = a;
4+
// readonly client: string;
5+
// private details: string;
6+
// public amount: number;
7+
function Invoice(client, details, amount) {
8+
this.client = client;
9+
this.details = details;
10+
this.amount = amount;
811
}
912
Invoice.prototype.format = function () {
1013
return this.client + " owes \u00A3" + this.amount + " for " + this.details;
@@ -16,8 +19,9 @@ var invTwo = new Invoice('luigi', 'work on the luigi website', 300);
1619
var invoices = [];
1720
invoices.push(invOne);
1821
invoices.push(invTwo);
19-
// invoices.push({ name: 'shaun' });
20-
console.log(invoices);
22+
invoices.forEach(function (inv) {
23+
console.log(inv.client, /*inv.details,*/ inv.amount, inv.format());
24+
});
2125
var form = document.querySelector('.new-item-form');
2226
console.log(form.children);
2327
// inputs

src/app.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// classes
22
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-
}
3+
// readonly client: string;
4+
// private details: string;
5+
// public amount: number;
6+
7+
constructor(
8+
readonly client: string,
9+
private details: string,
10+
public amount: number,
11+
){}
1212

1313
format() {
1414
return `${this.client} owes £${this.amount} for ${this.details}`;
@@ -21,9 +21,11 @@ const invTwo = new Invoice('luigi', 'work on the luigi website', 300);
2121
let invoices: Invoice[] = [];
2222
invoices.push(invOne)
2323
invoices.push(invTwo);
24-
// invoices.push({ name: 'shaun' });
2524

26-
console.log(invoices);
25+
invoices.forEach(inv => {
26+
console.log(inv.client, /*inv.details,*/ inv.amount, inv.format());
27+
})
28+
2729

2830

2931
const form = document.querySelector('.new-item-form') as HTMLFormElement;

0 commit comments

Comments
 (0)