forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathapp.js
More file actions
97 lines (89 loc) · 2.14 KB
/
app.js
File metadata and controls
97 lines (89 loc) · 2.14 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
let bookTitles = [
'Harry_Potter',
'The Great_Gatsby',
'To_Kill_a _Mockingbird',
'The_Hobbit',
'Fahrenheit_451',
'The Catcher_in_the_Rye',
'Pride_and_Prejudice',
];
function booksList() {
let bookList = document.createElement('div');
let ul = document.createElement('ul');
bookTitles.map(book => {
let li = document.createElement('li');
let bookNames = book.replace(/_/g, ' ');
li.appendChild(document.createTextNode(bookNames));
ul.appendChild(li);
return document.body.appendChild(bookList.appendChild(ul));
});
}
booksList();
let books = {
book1: {
book_title: 'Harry Potter',
author: 'J.K Rowling',
language: 'English',
cover_image: 'harrypotter.jpg',
},
book2: {
book_title: 'The Great Gatsby',
author: 'F. Scott Fitzgerald',
language: 'English',
cover_image: 'thegreat.jpg',
},
book3: {
book_title: 'To Kill a Mockingbird',
author: 'Harper Lee',
language: 'English',
cover_image: 'tokill.jpg',
},
book4: {
book_title: 'The Hobbit',
author: 'J.R.R. Tolkien',
language: 'English',
cover_image: 'thehobbit.jpg',
},
book5: {
book_title: 'Fahrenheit 451',
author: 'Ray Bradbury',
language: 'English',
cover_image: 'fahrenheit.jpg',
},
book6: {
book_title: 'The Catcher in the Rye',
author: 'J.D. Salinger',
language: 'English',
cover_image: 'thecatcher.jpg',
},
book7: {
book_title: 'Pride and Prejudice',
author: 'Jane Austen',
language: 'English',
cover_image: 'pap.jpg',
},
};
function booksDetails() {
let ul = document.createElement('ul');
for (let book in books) {
let li = document.createElement('li');
let img = document.createElement('IMG');
let p = document.createElement('p');
img.src = './img/' + books[book]['cover_image'];
li.appendChild(img);
p.innerHTML =
'Title: ' +
books[book]['book_title'] +
'</br>' +
'Author: ' +
books[book]['author'] +
'</br>' +
'Language: ' +
books[book]['language'];
li.appendChild(p);
ul.appendChild(li);
}
document.body.appendChild(ul);
}
booksDetails();