-
Notifications
You must be signed in to change notification settings - Fork 169
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (48 loc) · 1.53 KB
/
app.js
File metadata and controls
58 lines (48 loc) · 1.53 KB
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
53
54
55
56
57
58
const books = {
'978-83-7278-000-3': {
author: 'J.K. Rowling',
title: {
en: 'Harry Potter and the Philosopher\'s Stone',
pl: 'Harry Potter i Kamień Filozoficzny',
},
translator: {
en: null,
pl: 'Andrzej Polkowski',
}
},
'83-7278-007-2': {
author: 'J.K. Rowling',
title: {
en: 'Harry Potter and the Chamber of Secrets',
pl: 'Harry Potter i Komnata Tajemnic ',
},
translator: {
en: null,
pl: 'Andrzej Polkowski',
}
},
}
books.getAuthor = function(isbn) {
// w tym przypadku this === books
if(typeof this[isbn] === 'undefined') {
// taki ISBN nie istnieje w moim spisie
return null;
}
const author = this[isbn]['author'];
if(author) {
// zwracam informacje o autorze
return author;
}
// brak informacji o autorze
return false;
}
books.getTitle = function(isbn, lang) {
}
books.getTranslator = function(isbn, lang) {
}
console.log( books.getAuthor('978-83-7278-000-3') ); // J.K. Rowling
console.log( books.getAuthor('000-00-0000-000-0') ); // null
console.log( books.getTitle('978-83-7278-000-3', 'pl') ); // Harry Potter i Kamień Filozoficzny
console.log( books.getTitle('978-83-7278-000-3', 'en') ); // Harry Potter and the Philosopher's Stone
console.log( books.getTranslator('83-7278-007-2', 'pl') ); // Andrzej Polkowski
console.log( books.getTranslator('83-7278-007-2', 'en') ); // false