|
1 | 1 | 'use strict'; |
2 | 2 | { |
| 3 | + |
| 4 | + |
3 | 5 | const bookTitles = [ |
4 | | - // Replace with your own book titles |
5 | | - 'harry_potter_chamber_secrets' |
| 6 | + |
| 7 | + 'life_of_faith', |
| 8 | + 'the_sign_and_seal', |
| 9 | + 'the_book_of_genesius', |
| 10 | + 'the_book_of_reveletion', |
| 11 | + 'how_to_relate_with_children', |
| 12 | + 'what_is_man', |
| 13 | + 'even_the_stones_are_burning', |
| 14 | + 'life_of_hope', |
| 15 | + 'computer_architecture_and_organization', |
| 16 | + 'maximize_your_social_media' |
6 | 17 | ]; |
7 | 18 |
|
8 | 19 |
|
9 | | - // Replace with your own code |
10 | | - console.log(bookTitles); |
| 20 | + const booksInfo = { |
| 21 | + 'life_of_faith': { |
| 22 | + title: 'Life of faith', |
| 23 | + language: 'English', |
| 24 | + author: 'Pop Sheonoda' |
| 25 | + }, |
| 26 | + 'the_sign_and_seal': { |
| 27 | + title: 'The sign and seal', |
| 28 | + language: 'English', |
| 29 | + author: 'Graham Hancock' |
| 30 | + }, |
| 31 | + 'the_book_of_genesius': { |
| 32 | + title: 'The book of Genesius', |
| 33 | + language: 'Tigrigna', |
| 34 | + author: 'prophet Moses' |
| 35 | + }, |
| 36 | + 'the_book_of_reveletion': { |
| 37 | + title: 'The book of Reveletion', |
| 38 | + language: 'Geez', |
| 39 | + author: 'St.John' |
| 40 | + }, |
| 41 | + 'how_to_relate_with_children': { |
| 42 | + title: 'How to relate with children', |
| 43 | + language: 'English', |
| 44 | + author: 'Pop Sheonoda' |
| 45 | + }, |
| 46 | + 'what_is_man': { |
| 47 | + title: 'What is man', |
| 48 | + language: 'English', |
| 49 | + author: 'Pop Sheonoda' |
| 50 | + }, |
| 51 | + 'even_the_stones_are_burning': { |
| 52 | + title: 'Even the stones are burning', |
| 53 | + language: 'English', |
| 54 | + author: 'Roy Patheman' |
| 55 | + }, |
| 56 | + 'life_of_hope': { |
| 57 | + title: 'Life of hope', |
| 58 | + language: 'English', |
| 59 | + author: 'Pop Sheonoda' |
| 60 | + }, |
| 61 | + 'computer_architecture_and_organization': { |
| 62 | + title: 'Computer architecture and organization', |
| 63 | + language: 'English', |
| 64 | + author: 'Kanj Sharma' |
| 65 | + }, |
| 66 | + 'maximize_your_social_media': { |
| 67 | + title: 'Maximize your social media', |
| 68 | + language: 'English', |
| 69 | + author: 'Neal Sheffar' |
| 70 | + } |
| 71 | + |
| 72 | + } |
| 73 | + |
| 74 | + const bookCover = { |
| 75 | + life_of_faith: 'image/life_of_faith.jpg', |
| 76 | + the_sign_and_seal: 'image/the_sign_and_the_seal.jpg', |
| 77 | + the_book_of_genesius: 'image/genesius.jpg', |
| 78 | + the_book_of_reveletion: 'image/revelation.jpg', |
| 79 | + how_to_relate_with_children: 'image/how_to_relate_with_children.jpg', |
| 80 | + what_is_man: 'image/what_is_man.jpg', |
| 81 | + even_the_stones_are_burning: 'image/even_the_stones_are_burning.jpg', |
| 82 | + life_of_hope: 'image/life_of_hope.jpg', |
| 83 | + computer_architecture_and_organization: 'image/computer_architecture_and_organization.jpg', |
| 84 | + maximize_your_social_media: 'image/maximize_your_social_media.jpg' |
| 85 | + |
| 86 | + }; |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + function renderBookInfo() { |
| 91 | + |
| 92 | + for (let key of bookTitles) { |
| 93 | + |
| 94 | + let booksContainer = document.createElement('div'); |
| 95 | + document.body.appendChild(booksContainer); |
| 96 | + let h2 = document.createElement('h2'); |
| 97 | + h2.innerHTML = booksInfo[key].title; |
| 98 | + booksContainer.appendChild(h2); |
| 99 | + |
| 100 | + let p = document.createElement('p'); |
| 101 | + p.innerHTML = 'Language: ' + booksInfo[key].language; |
| 102 | + booksContainer.appendChild(p); |
| 103 | + |
| 104 | + p = document.createElement('p'); |
| 105 | + p.innerHTML = 'Author: ' + booksInfo[key].author; |
| 106 | + booksContainer.appendChild(p); |
| 107 | + |
| 108 | + let imageLink = bookCover[key]; |
| 109 | + let img = document.createElement('img'); |
| 110 | + img.setAttribute('src', imageLink); |
| 111 | + img.setAttribute("height", '680'); |
| 112 | + img.setAttribute("width", '600'); |
| 113 | + img.setAttribute("alt", key); |
| 114 | + booksContainer.appendChild(img); |
| 115 | + |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | +function main(){ |
| 120 | + |
| 121 | + |
| 122 | + let h1 = document.createElement('h1'); |
| 123 | + h1.innerText = 'The Basic Info of the 10 books I have read'; |
| 124 | + document.body.appendChild(h1); |
| 125 | + renderBookInfo(); |
| 126 | +} |
| 127 | + |
| 128 | + |
| 129 | + window.addEventListener('load', main); |
11 | 130 | } |
| 131 | + |
0 commit comments