|
2 | 2 | { |
3 | 3 | const bookTitles = [ |
4 | 4 | // Replace with your own book titles |
5 | | - 'harry_potter_chamber_secrets' |
| 5 | + "the_vegetarian", "watership_down", |
| 6 | + |
| 7 | + "adventures_sherlock_holmes", "alchemist", |
| 8 | + |
| 9 | + "frankenstein", "city_of_thieves", "gone_with_the_wind", |
| 10 | + |
| 11 | + "kill_a_mockingbird", "war_and_peace", "things_fall_apart" |
6 | 12 | ]; |
7 | 13 |
|
8 | 14 |
|
9 | 15 | // Replace with your own code |
10 | | - console.log(bookTitles); |
| 16 | + |
| 17 | + const booksDetails = { |
| 18 | + |
| 19 | + the_vegetarian : {title: "The Vegetarian", lang: "English", author: "Han Kang"}, |
| 20 | + |
| 21 | + watership_down : {title: "Watership Down", lang: "English", author: "Richard Adams"}, |
| 22 | + |
| 23 | + adventures_sherlock_holmes : {title: "The Adventures of Sherlock Holmes", lang: "English", author: "Arthur Conan Doyle"}, |
| 24 | + |
| 25 | + alchemist : {title: "Alchemist", lang: "English", author: "Paulo Coelho"}, |
| 26 | + |
| 27 | + frankenstein : {title: "Frankenstein", lang: "English", author: "Mary Shelley"}, |
| 28 | + |
| 29 | + city_of_thieves : {title: "City of Thieves", lang: "English", author:"David Benioff"}, |
| 30 | + |
| 31 | + gone_with_the_wind : {title: "Gone With the Wind", lang: "English", author: "Margaret Mitchell"}, |
| 32 | + |
| 33 | + kill_a_mockingbird : {title: "To Kill A Mockingbird", lang: "English", author: "Harper Lee"}, |
| 34 | + |
| 35 | + war_and_peace : {title: "War and Peace", lang: "English", author: "Leo Tolstoy"}, |
| 36 | + |
| 37 | + things_fall_apart : {title: "Things Fall Apart", lang: "English", author: "Chinua Achebe"} |
| 38 | + |
| 39 | +}; |
| 40 | + |
| 41 | +const bookCovers = { |
| 42 | + the_vegetarian : "https://static.abebookscdn.com/cdn/com/images/100-books/Vegetarian,%20The.jpg" , |
| 43 | + watership_down : "https://static.abebookscdn.com/cdn/com/images/100-books/Watership%20Down.jpg", |
| 44 | + adventures_sherlock_holmes : "https://static.abebookscdn.com/cdn/com/images/100-books/Adventures%20of%20Sherlock%20Holmes.jpg", |
| 45 | + alchemist : "https://static.abebookscdn.com/cdn/com/images/100-books/Alchemist.jpg", |
| 46 | + frankenstein : "https://static.abebookscdn.com/cdn/com/images/100-books/Frankenstein.jpg", |
| 47 | + city_of_thieves : "https://static.abebookscdn.com/cdn/com/images/100-books/City%20of%20Thieves.jpg", |
| 48 | + gone_with_the_wind : "https://static.abebookscdn.com/cdn/com/images/100-books/Gone%20With%20the%20Wind.jpg", |
| 49 | + kill_a_mockingbird : "https://static.abebookscdn.com/cdn/com/images/100-books/To%20Kill%20a%20Mockingbird.jpg", |
| 50 | + war_and_peace : "https://static.abebookscdn.com/cdn/com/images/100-books/War%20and%20Peace.jpg", |
| 51 | + things_fall_apart : "https://static.abebookscdn.com/cdn/com/images/100-books/Things%20Fall%20Apart.jpg", |
| 52 | +}; |
| 53 | +} |
| 54 | + |
| 55 | +function generateList() { |
| 56 | + const newList = document.createElement('ul'); |
| 57 | + document.body.appendChild(generateList); |
| 58 | + for (let i = 0; i < bookTitles.length; i++) { |
| 59 | + const list = document.createElement("li"); |
| 60 | + newList.appendChild(li); |
| 61 | + newList.innerHTML = (bookTitles)[i]; |
| 62 | + const bookImages = document.createElement("img"); |
| 63 | + li.appendchild(bookImages); |
| 64 | + li.setAttribute("id", Object.keys(bookCovers)[i]); |
| 65 | + |
| 66 | + const para = document.createElement("p"); |
| 67 | + li.appendChild(para); |
| 68 | + p.innerHTML = ("lang :" + (Object.values(booksDetails)[i]).lang); |
| 69 | + |
| 70 | + const para1 = document.createElement("p"); |
| 71 | + li.appendChild(para1); |
| 72 | + p1.innerHTML = ("lang : " + (Object.values(booksDetails)[i]).author); |
| 73 | + |
| 74 | + } |
| 75 | + |
| 76 | + return newList; |
| 77 | + |
| 78 | + } |
| 79 | + |
| 80 | + console.log(newList); |
| 81 | + |
| 82 | + |
| 83 | +// const head1 = document.createElement("h1"); |
| 84 | +// Li.appenChild(head1); |
| 85 | + |
| 86 | +// h1.innerHTML = (Object.values(booksDetails)[i]).title; |
| 87 | + |
| 88 | +// const bookImages = document.createElement("img"); |
| 89 | +// li.appendchild(bookImages); |
| 90 | +// li.setAttribute("id", Object.keys(bookCovers)[i]); |
| 91 | + |
| 92 | +// const para = document.createElement("p"); |
| 93 | + |
| 94 | +// li.appendChild(para); |
| 95 | + |
| 96 | +// p.innerHTML = ("lang :" + (Object.values(booksDetails)[i]).lang); |
| 97 | + |
| 98 | +// const para1 = document.createElement("p"); |
| 99 | + |
| 100 | +// li.appendChild(para1); |
| 101 | + |
| 102 | +// p1.innerHTML = ("lang : " + (Object.values(booksDetails)[i]).author); |
| 103 | + |
| 104 | +// console.log(newList); |
11 | 105 | } |
0 commit comments