forked from truecodersio/JavaScript_OOP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassArticle.js
More file actions
31 lines (27 loc) · 765 Bytes
/
ClassArticle.js
File metadata and controls
31 lines (27 loc) · 765 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
class Article {
constructor(title, text, author) {
this.title = title;
this.text = text;
this.author = author;
this.date = new Date();
}
read() {
console.log(this.text);
}
}
class Blog extends article {
constructor(title, text, author, tags) {
super(title, text, author, tags);
this.tags = tags;
}
share(shareType) {
if (shareType) {
console.log(`sharing on ${shareType}...`);
} else {
console.log("no share type selected")
}
}
let blog = new blog("Best Halloween Costumes 2021", "Streets cones are IN!", "Ben Bryant", ["halloween"], ["trick or treat"]);
console.log(blog);
blog.read();
blog.share("twitter");