-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglossary.js
52 lines (42 loc) · 1.24 KB
/
glossary.js
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
50
51
52
// let's init'd the glossary class
class Glossary {
// define glossary term
constructor(name, definitionList = []) {
this.name = name;
this.definitionList = definitionList;
}
// add dedinition to the list
addDefinitionList(definitionList) {
this.definitionList.push(definitionList);
console.log("one definition added");
}
}
// let's init'd the glossary item class
//// it will be used for appending the Glossary definitionList
class GlossaryItem {
// init'd constructor for glossary item
constructor(definition, author, year, title, publisher) {
this.definition = definition;
this.author = author;
this.year = year;
this.title = title;
this.publisher = publisher;
}
// get author name based on APA citation
getAuthor() {
const prename = this.author.split(" ");
const firstname = prename.slice(0, prename.length - 1);
return `${prename[prename.length - 1]}, ${firstname.join(" ")}`;
}
// get citation reference based on APA
getAPA() {
return `${this.getAuthor()} (${this.year}). <em>${this.title}</em>. ${this.publisher}`;
}
}
// testing is allowed from here
// code
// testing is allowed until here
module.exports = {
Glossary: Glossary,
GlossaryItem: GlossaryItem
};