Skip to content

Week3 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
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
correct
  • Loading branch information
Nouransaeed committed Aug 15, 2019
commit 5e575a9cd8af656f6ad88e750c8383048523881b
143 changes: 54 additions & 89 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,65 @@
'use strict';

const titles = [
'harry_potter_chamber_secrets',
'alchemist', //Paulo coelho
'paula',
'orlando',
'divine-comedy',
'the-odyssey',
];

let objBooks = {
"harry_potter_chamber_secrets": {
title :"harry_potter_chamber_secrets",

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an extra space here. In fact, I think there looks like to be lots of strange spacing. Can you run prettier on your files so they fix the formatting issues?

'use strict'
const books = [
{
title :"Harry Potter Chamber of Secrets",
language:"english",
author:"Joanne K. Rowling"
author:"Joanne K. Rowling",

},
"alchemist": {
title:"alchemist",

{
title:"Alchemist",
language:"english",
author:"paulo-coelho",
author:"paulo-co",

},

"paula": {
title:"paula",
language:"english",
author:"isabel allende",
},
"orlando":
{
title:"orlando",

language:"english",

author:"virgina wolf",

},
"divine-comedy" :
{

title:"divine-comedy",

language:"English",

author:"dante",

},

"the-odyssey":
{

title:"the-odyssey",

language: "english",

author:"homeros",

}
}

const ul = document.createElement('ul');

ul.setAttribute('id', 'booktitle');




/* function listBooks() {
// let i = 0; // this is unnecessary
let ul = document.createElement('ul')
for (let i = 0; i < title.length; i++) {
let li = document.createElement('li');
li.textContent = title[i];
ul.appendChild(li);
}
// we don't do anything with the ul
// ???
}

document.body.appendChild(ul); // where does ul come from? This will throw an error.
document.body.onload = listBooks;
const objBooksArr = [];
for (const newListBooks in objBooks) {
console.log(newListBooks);
objBooksArr.push(objBooks[newListBooks])
}
{
title:"Paula",
language:"english",
author:"isabel allende",

},

{

const bookPic = {
title:"Orlando",
language:"english",
author:"virginia-wolf",

'harry_potter_chamber_secrets':potter.jpg ,
'alchemist':alchemist,
'paula' :paula.jpg,
'orlando':woolf.jpg,
'divine-comedy':divine.jpg,
'the-odyssey' :odyssy.jpg,
};
},

{
title:"Divine Comedy",
language:"English",
author:"dante",

},

{
title:"The Odyssey",
language: "english",
author:"Homeros",

},

]

function createAndAppend(parent,typ,attributes={}) {

const elem = document.createElement(typ)

parent.appendChild(elem)

for (const key in attributes)

elem[key] = attributes[key]
return elem
}

const ul = createAndAppend(document.body, 'ul', {})
for (const index in books) {
const book = books[index]
createAndAppend(ul, 'li', {value : index, innerHTML: book.title})
}
Empty file added Week1/homework/app2.js
Empty file.
7 changes: 3 additions & 4 deletions Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>
<html>
<head>
<title> Book Titles</title>
<script src="app.js"></script>

</head>
<body>
<div id="obj-books-Arr"></div>
<script src="app.js"></script>
</body>
</html>
</html>
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy