Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 14, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
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
98 changes: 96 additions & 2 deletions 98 Week1/homework/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,104 @@
{
const bookTitles = [
Copy link

Choose a reason for hiding this comment

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

This should be on its own branch, not master.
As a result of doing this correctly, I would not be seeing all the week1 diffs in week2's homework. 😄

// Replace with your own book titles
'harry_potter_chamber_secrets'
"the_vegetarian", "watership_down",

"adventures_sherlock_holmes", "alchemist",

"frankenstein", "city_of_thieves", "gone_with_the_wind",

"kill_a_mockingbird", "war_and_peace", "things_fall_apart"
];


// Replace with your own code
console.log(bookTitles);

const booksDetails = {

the_vegetarian : {title: "The Vegetarian", lang: "English", author: "Han Kang"},

watership_down : {title: "Watership Down", lang: "English", author: "Richard Adams"},

adventures_sherlock_holmes : {title: "The Adventures of Sherlock Holmes", lang: "English", author: "Arthur Conan Doyle"},

alchemist : {title: "Alchemist", lang: "English", author: "Paulo Coelho"},

frankenstein : {title: "Frankenstein", lang: "English", author: "Mary Shelley"},

city_of_thieves : {title: "City of Thieves", lang: "English", author:"David Benioff"},

gone_with_the_wind : {title: "Gone With the Wind", lang: "English", author: "Margaret Mitchell"},

kill_a_mockingbird : {title: "To Kill A Mockingbird", lang: "English", author: "Harper Lee"},

war_and_peace : {title: "War and Peace", lang: "English", author: "Leo Tolstoy"},

things_fall_apart : {title: "Things Fall Apart", lang: "English", author: "Chinua Achebe"}

};

const bookCovers = {
the_vegetarian : "https://static.abebookscdn.com/cdn/com/images/100-books/Vegetarian,%20The.jpg" ,
watership_down : "https://static.abebookscdn.com/cdn/com/images/100-books/Watership%20Down.jpg",
adventures_sherlock_holmes : "https://static.abebookscdn.com/cdn/com/images/100-books/Adventures%20of%20Sherlock%20Holmes.jpg",
alchemist : "https://static.abebookscdn.com/cdn/com/images/100-books/Alchemist.jpg",
frankenstein : "https://static.abebookscdn.com/cdn/com/images/100-books/Frankenstein.jpg",
city_of_thieves : "https://static.abebookscdn.com/cdn/com/images/100-books/City%20of%20Thieves.jpg",
gone_with_the_wind : "https://static.abebookscdn.com/cdn/com/images/100-books/Gone%20With%20the%20Wind.jpg",
kill_a_mockingbird : "https://static.abebookscdn.com/cdn/com/images/100-books/To%20Kill%20a%20Mockingbird.jpg",
war_and_peace : "https://static.abebookscdn.com/cdn/com/images/100-books/War%20and%20Peace.jpg",
things_fall_apart : "https://static.abebookscdn.com/cdn/com/images/100-books/Things%20Fall%20Apart.jpg",
};
}

function generateList() {
const newList = document.createElement('ul');
document.body.appendChild(generateList);
for (let i = 0; i < bookTitles.length; i++) {
const list = document.createElement("li");
newList.appendChild(li);
newList.innerHTML = (bookTitles)[i];
const bookImages = document.createElement("img");
li.appendchild(bookImages);
li.setAttribute("id", Object.keys(bookCovers)[i]);

const para = document.createElement("p");
li.appendChild(para);
p.innerHTML = ("lang :" + (Object.values(booksDetails)[i]).lang);

const para1 = document.createElement("p");
li.appendChild(para1);
p1.innerHTML = ("lang : " + (Object.values(booksDetails)[i]).author);

}

return newList;

}

console.log(newList);


// const head1 = document.createElement("h1");
// Li.appenChild(head1);

// h1.innerHTML = (Object.values(booksDetails)[i]).title;

// const bookImages = document.createElement("img");
// li.appendchild(bookImages);
// li.setAttribute("id", Object.keys(bookCovers)[i]);

// const para = document.createElement("p");

// li.appendChild(para);

// p.innerHTML = ("lang :" + (Object.values(booksDetails)[i]).lang);

// const para1 = document.createElement("p");

// li.appendChild(para1);

// p1.innerHTML = ("lang : " + (Object.values(booksDetails)[i]).author);

// console.log(newList);
}
15 changes: 15 additions & 0 deletions 15 Week2/homework/maartjes_work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,18 @@ const tuesday = [
const tasks = monday.concat(tuesday);

// Add your code here
// Map the tasks to durations in hours.
const hours = tasks.map(function(taskHour){
return taskHour.duration / 60;
})
console.log(hours);//[ 3,2,0.33,3.33,4,3,0.16,3.33,0.66 ]

// Filter out everything that took less than two hours
const earningHours = hours.filter(function(earningHour){
return earningHour >= 2;
})
console.log(earningHours);//[ 3, 2, 3.33, 4, 3, 3.33 ]

// Multiply the duration per-hour rate and sum it all up.
const totalEarning = earningHours.map(hours => hours * 9)
.reduce((money, payment) => money + payment);
7 changes: 7 additions & 0 deletions 7 Week2/homework/map_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
const numbers = [1, 2, 3, 4];

// Add your code here
const numbers = [1, 2, 3, 4];
Copy link

Choose a reason for hiding this comment

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

Nice job here.
Did you run this? Because it should have given you an error, you are defining numbers twice as a constant.

Copy link

Choose a reason for hiding this comment

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

Have you thought about using arrow functions (=>) here? They can make things more readable, and less typing. 😛

const newNumbers = numbers.filter(function(number){
return (number % 2 !== 0);
}).map(function(number){
return number * 2;
});
console.log("The doubled numbers are", newNumbers); // [2, 6]
3 changes: 3 additions & 0 deletions 3 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.