-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-node-app.ts
More file actions
49 lines (43 loc) · 857 Bytes
/
simple-node-app.ts
File metadata and controls
49 lines (43 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as fs from 'fs';
import * as path from 'path';
type Item = {
name: string;
price: number;
quantity: number;
}
type ShoppingList = {
date: string;
items: Item[];
}
const shoppingList: ShoppingList = {
date: "2022-01-08T03:30:00.000Z",
items: [
{
"name": "เนื้อหมู",
"price": 999,
"quantity": 1
},
{
"name": "น้ำดื่ม",
"price": 10,
"quantity": 12
},
{
"name": "ผักชี",
"price": 30,
"quantity": 2
}
]
};
const calculateTotalPrice = (list: Item[]) => {
// calculate total price from list of items
return 0;
}
const main = () => {
const totalPrice = calculateTotalPrice([]);
fs.writeFileSync(
path.join(__dirname, './total_price.txt'),
Buffer.from(`${totalPrice.toString()} baht`)
);
};
main();