|
1 |
| -'use strict'; |
2 |
| -{ |
3 |
| - const bookTitles = [ |
4 |
| - // Replace with your own book titles |
5 |
| - 'harry_potter_chamber_secrets' |
6 |
| - ]; |
| 1 | +let theBooksIRead = [ |
| 2 | + "harry_potter_and_the_deathly_hallows", |
| 3 | + "The_Baloch_and_Balochistan", |
| 4 | + "The_Baloch_Conflict_with_Iran_and_Pakistan", |
| 5 | + "Balochistan:_At_a_Crossroads_Reviews", |
| 6 | + "The_Alchemist", |
| 7 | + "The_Night_Bird", |
| 8 | + " From_Sand_and_Ash", |
| 9 | + "Dead_Certain", |
| 10 | + " I_Am_Watching_You ", |
| 11 | + "You_The_Letter_by_Kathryn_Hughes" |
| 12 | +]; |
7 | 13 |
|
| 14 | +//console.log(theBooksIRead); |
8 | 15 |
|
9 |
| - // Replace with your own code |
10 |
| - console.log(bookTitles); |
| 16 | +function generateItems() { |
| 17 | + let ul = document.createElement("ul"); |
| 18 | + |
| 19 | + theBooksIRead.forEach(function (book) { |
| 20 | + console.log(book); |
| 21 | + |
| 22 | + let li = document.createElement("li"); |
| 23 | + ul.appendChild(li); |
| 24 | + li.innerHTML += book; |
| 25 | + }); |
| 26 | + document.body.appendChild(ul); |
| 27 | +} |
| 28 | +//generateItems(); |
| 29 | + |
| 30 | +let myBooksInformation = { |
| 31 | + harry_potter_and_the_deathly_hallows: { |
| 32 | + title: "Harry Potter and the Deathly Hallows", |
| 33 | + language: "English", |
| 34 | + author: "J. K. Rowling" |
| 35 | + }, |
| 36 | + les_miserables: { |
| 37 | + title: "The Baloch and Balochistan", |
| 38 | + language: "English", |
| 39 | + author: "Naseer Dashti" |
| 40 | + }, |
| 41 | + da_vinci_code: { |
| 42 | + title: " The Baloch Conflict with Iran and Pakistan", |
| 43 | + language: "English", |
| 44 | + author: "Naseer Dashti" |
| 45 | + }, |
| 46 | + to_kill_a_mockingbird: { |
| 47 | + title: "Balochistan: At a Crossroads Reviews", |
| 48 | + language: "English", |
| 49 | + author: "Willem Marx" |
| 50 | + }, |
| 51 | + hero_of_our_time: { |
| 52 | + title: "The Alchemist ", |
| 53 | + language: "English", |
| 54 | + author: "PAULO COELHO" |
| 55 | + }, |
| 56 | + don_quixote: { |
| 57 | + title: "The Night Bird", |
| 58 | + language: "English", |
| 59 | + author: "Brian Freeman" |
| 60 | + }, |
| 61 | + returning_to_haifa: { |
| 62 | + title: "From Sand and Ash", |
| 63 | + language: "English", |
| 64 | + author: "Amy Harmon" |
| 65 | + }, |
| 66 | + beirut_nightmares: { |
| 67 | + title: "Dead Certain", |
| 68 | + language: "Englsih", |
| 69 | + author: "Adam Mitzner" |
| 70 | + }, |
| 71 | + doctor_zhivago: { |
| 72 | + title: " I Am Watching You", |
| 73 | + language: "English", |
| 74 | + author: "Teresa Driscoll" |
| 75 | + }, |
| 76 | + song_of_ice_and_fire: { |
| 77 | + title: "The Letter' by Kathryn Hughes", |
| 78 | + language: "English", |
| 79 | + author: " Kathryn Hughes" |
| 80 | + } |
| 81 | +}; |
| 82 | + |
| 83 | +function generateBooksList() { |
| 84 | + let myBooksInfo = document.createElement("ul"); |
| 85 | + document.body.appendChild(myBooksInfo); |
| 86 | + |
| 87 | + for (let booksId in myBooksInformation) { |
| 88 | + let li = document.createElement("li"); |
| 89 | + li.setAttribute("id", booksId); |
| 90 | + myBooksInfo.appendChild(li); |
| 91 | + |
| 92 | + let b_title = document.createElement("h2"); |
| 93 | + li.appendChild(b_title); |
| 94 | + b_title.innerHTML = myBooksInformation[booksId].title; |
| 95 | + |
| 96 | + let b_language = document.createElement("p"); |
| 97 | + li.appendChild(b_language); |
| 98 | + b_language.innerHTML = myBooksInformation[booksId].language; |
| 99 | + |
| 100 | + let b_author = document.createElement("h4"); |
| 101 | + li.appendChild(b_author); |
| 102 | + b_author.innerHTML = "by : < " + myBooksInformation[booksId].author + " >"; |
| 103 | + }; |
| 104 | +} |
| 105 | + |
| 106 | +generateBooksList(); |
| 107 | + |
| 108 | +let MyBookCovers = { |
| 109 | + harry_potter_and_the_deathly_hallows: "https://media.bloomsbury.com/rep/bj/9780747591061.jpg", |
| 110 | + The_Baloch_and_Balochistan: "https://images-na.ssl-images-amazon.com/images/I/51O3nqWcmqL._SX322_BO1,204,203,200_.jpg", |
| 111 | + The_Baloch_Conflict_with_Iran_and_Pakistan: "https://thewire.in/wp-content/uploads/2017/12/Baloch-conflict.png", |
| 112 | + Balochistan_At_a_Crossroads_Reviews: "https://images-na.ssl-images-amazon.com/images/I/81n%2B%2B6UluJL.jpg", |
| 113 | + The_Alchemist: "https://n1.sdlcdn.com/imgs/b/y/q/624303691271_1-ed95c.jpg", |
| 114 | + The_Night_Bird: "https://images-na.ssl-images-amazon.com/images/I/51HrCVynYBL.jpg", |
| 115 | + From_Sand_and_Ash: "https://images-na.ssl-images-amazon.com/images/I/51KRuC%2BmItL.jpg", |
| 116 | + Dead_Certain: "https://images-na.ssl-images-amazon.com/images/I/5132qfIGVwL._SY346_.jpg", |
| 117 | + I_Am_Watching_You: "https://images-na.ssl-images-amazon.com/images/I/51PeVt0WznL._SY346_.jpg", |
| 118 | + You_The_Letter_by_Kathryn_Hughes: "https://images-na.ssl-images-amazon.com/images/I/51VE8UMU35L.jpg" |
| 119 | +}; |
| 120 | + |
| 121 | +function bookCovers() { |
| 122 | + for (let j in myBooksInformation) { |
| 123 | + var img = document.createElement("img"); |
| 124 | + img.setAttribute("src", MyBookCovers[j]); |
| 125 | + img.setAttribute("alt", j); |
| 126 | + let bookImg = document.getElementById(j); |
| 127 | + bookImg.appendChild(img); |
| 128 | + } |
11 | 129 | }
|
| 130 | +bookCovers(); |
0 commit comments