-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.ts
More file actions
37 lines (27 loc) · 830 Bytes
/
data.ts
File metadata and controls
37 lines (27 loc) · 830 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
// Example Typescript code with a JSONC data file
class Player {
name: string;
level: number;
isOnline: boolean;
constructor(name: string, level: number, isOnline: boolean) {
this.name = name;
this.level = level;
this.isOnline = isOnline;
}
toString() {
return `${this.name} (Lvl. ${this.level})`;
}
}
const players = [
// This ain't no game, kid!
new Player("art3mis", 10, true),
// I'm not a gunter, I'm a gamer.
new Player("parzival", 5, false),
// It is on like Red Dawn!
new Player("aech", 7, true),
// I support the OASIS.
new Player("gunter", 2, false),
];
console.log(`There are ${players.length} players in the game.`);
const onlinePlayers = players.filter((player) => player.isOnline).join(", ");
console.log(`The following players are online: ${onlinePlayers}`);