Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
week01
  • Loading branch information
EliaYazdi committed Aug 6, 2019
commit dacdc488c4c5cbb3009ebfebfe041791f68f91ef
91 changes: 22 additions & 69 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,27 @@ const bookList = [
'the-outsiders',
'little-women',
];
//console.log(bookList);
//this is how I printed my array in the DOM but not like a list. like a line!
document.querySelector('#myArr').innerHTML = `<li>${bookList}</li>`

//Now I want to creat an unordered list out of the bookList array

function createList() {
let uList = document.createElement('ul');
uList.setAttribute('id', 'li');
document.body.appendChild(uList);


for (let index in bookList) {
let eachBook = document.createElement('li');
uList.appendChild(eachBook);

eachBook.textContent = bookList[index];
}
}
createList();

//Now I have an object of my must read books information

let booksInfo = {
book1: {
Expand Down Expand Up @@ -38,71 +58,4 @@ let booksInfo = {
author: 'Louisa May',
language: 'English'
}
};

book1Arr = [];
for (const i in booksInfo.book1) {
book1Arr.push(booksInfo.book1[i]);
};

document.querySelector('#first').innerHTML = `<li>${book1Arr}</li>`;


//creat UL

//make an object containing info

/*let ul = document.createElement('ul');
document.getElementById('books').appendChild(ul);

bookList.forEach(book => {
let li = document.createElement('li');
ul.appendChild(li);
li.innerHTML += book;
});
*/

/*const bookInfo = {
'Elia1': {
properties: {
name: 'Elia 1',
Author: 'Elia the Famouse',
Language: 'English',
img: 'eli.jpg',
},
},
'Elia2': {
properties: {
name: 'Elia 2',
Author: 'Elia the Famouse',
Language: 'English',
img: 'eli.jpg',
},
},
'Elia3': {
properties: {
name: 'Elia 3',
Author: 'Elia the Famouse',
Language: 'English',
img: 'eli.jpg',
},
},
'Elia4': {
properties: {
name: 'Elia 4',
Author: 'Elia the Famouse',
Language: 'English',
img: 'eli.jpg',
},
},
'Elia5': {
properties: {
name: 'Elia 5',
Author: 'Elia the Famouse',
Language: 'English',
img: 'eli.jpg',
},
}
}

document.getElementById('inf').innerHTML = `<li>${bookInfo.key}</li>`; */
};
11 changes: 3 additions & 8 deletions Week1/homework/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@


<body>
<h1>My Must Read Books</h1>

<div id="first">
<p id="info1"></p>
</div>

<div id="second"></div>
<div id="third"></div>
<div id="forth"></div>
<div id="fifth"></div>
<p id="myArr"></p>
<hr></hr>

<script src="app.js">
</script>
Expand Down