From c7910deca8bbb7e4f538665517b3a5c2e26fe896 Mon Sep 17 00:00:00 2001
From: Keyya <43468230+keyyaali@users.noreply.github.com>
Date: Fri, 16 Nov 2018 15:02:47 +0100
Subject: [PATCH 1/4] Update map_filter.js
---
Week2/homework/map_filter.js | 62 +++++++++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/Week2/homework/map_filter.js b/Week2/homework/map_filter.js
index b6af22631..eba535db6 100644
--- a/Week2/homework/map_filter.js
+++ b/Week2/homework/map_filter.js
@@ -1,5 +1,65 @@
'use strict';
+// Example implementation of map, filter, forEach
+// See also: https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/map_filter.md
+
const numbers = [1, 2, 3, 4];
-// Add your code here
+function map(arr, mapFn) {
+ const result = [];
+ for (let i = 0; i < arr.length; i++) {
+ const elem = arr[i];
+ const mappedValue = mapFn(elem, i, arr);
+ result.push(mappedValue);
+ }
+ return result;
+}
+
+console.log('\n.map()');
+console.log(map(numbers, x => x * x));
+console.log(numbers.map(x => x * x));
+
+function filter(arr, predicateFn) {
+ const result = [];
+ for (let i = 0; i < arr.length; i++) {
+ const elem = arr[i];
+ if (predicateFn(elem, i, arr)) {
+ result.push(arr[i]);
+ }
+ }
+ return result;
+}
+
+console.log('\n.filter()');
+console.log(filter(numbers, x => x % 2 === 0));
+console.log(numbers.filter(x => x % 2 === 0));
+
+function reduce(arr, reducerFn, initialValue) {
+ let accumulator = initialValue;
+ for (let i = 0; i < arr.length; i++) {
+ const elem = arr[i];
+ accumulator = reducerFn(accumulator, elem, i, arr);
+ }
+ return accumulator;
+}
+
+console.log('\n.reduce()');
+console.log(reduce(numbers, (acc, number) => acc + number, 0));
+console.log(numbers.reduce((acc, number) => acc + number, 0));
+
+function forEach(arr, func) {
+ for (let i = 0; i < arr.length; i++) {
+ const elem = arr[i];
+ func(elem, i, arr);
+ }
+}
+
+console.log('\n.forEach()');
+
+let sum = 0;
+forEach(numbers, x => sum += x);
+console.log(sum);
+
+sum = 0;
+numbers.forEach(x => sum += x);
+console.log(sum);
From a64586c8b7c8b36ae90b5ae7e1ebbeb746d451e4 Mon Sep 17 00:00:00 2001
From: Keyya <43468230+keyyaali@users.noreply.github.com>
Date: Sat, 17 Nov 2018 16:50:37 +0100
Subject: [PATCH 2/4] Update index.html
---
Week1/homework/index.html | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/Week1/homework/index.html b/Week1/homework/index.html
index b22147cd1..c967e6717 100644
--- a/Week1/homework/index.html
+++ b/Week1/homework/index.html
@@ -1 +1,19 @@
-
\ No newline at end of file
+DOCTYPE html>
+
+
+
+
+
+ My Favorite Books
+
+
+
+
+
+
+
My Favorite Books
+
+
+
+
+
From d0464d7dbdc4520121c7cf516963d5c67bb4582b Mon Sep 17 00:00:00 2001
From: Keyya <43468230+keyyaali@users.noreply.github.com>
Date: Sun, 18 Nov 2018 18:58:47 +0100
Subject: [PATCH 3/4] Update app.js
---
Week1/homework/app.js | 135 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 127 insertions(+), 8 deletions(-)
diff --git a/Week1/homework/app.js b/Week1/homework/app.js
index ffef836dc..6826d9084 100644
--- a/Week1/homework/app.js
+++ b/Week1/homework/app.js
@@ -1,11 +1,130 @@
-'use strict';
-{
- const bookTitles = [
- // Replace with your own book titles
- 'harry_potter_chamber_secrets'
- ];
+let theBooksIRead = [
+ "harry_potter_and_the_deathly_hallows",
+ "The_Baloch_and_Balochistan",
+ "The_Baloch_Conflict_with_Iran_and_Pakistan",
+ "Balochistan:_At_a_Crossroads_Reviews",
+ "The_Alchemist",
+ "The_Night_Bird",
+ " From_Sand_and_Ash",
+ "Dead_Certain",
+ " I_Am_Watching_You ",
+ "You_The_Letter_by_Kathryn_Hughes"
+];
+//console.log(theBooksIRead);
- // Replace with your own code
- console.log(bookTitles);
+function generateItems() {
+ let ul = document.createElement("ul");
+
+ theBooksIRead.forEach(function (book) {
+ console.log(book);
+
+ let li = document.createElement("li");
+ ul.appendChild(li);
+ li.innerHTML += book;
+ });
+ document.body.appendChild(ul);
+}
+//generateItems();
+
+let myBooksInformation = {
+ harry_potter_and_the_deathly_hallows: {
+ title: "Harry Potter and the Deathly Hallows",
+ language: "English",
+ author: "J. K. Rowling"
+ },
+ les_miserables: {
+ title: "The Baloch and Balochistan",
+ language: "English",
+ author: "Naseer Dashti"
+ },
+ da_vinci_code: {
+ title: " The Baloch Conflict with Iran and Pakistan",
+ language: "English",
+ author: "Naseer Dashti"
+ },
+ to_kill_a_mockingbird: {
+ title: "Balochistan: At a Crossroads Reviews",
+ language: "English",
+ author: "Willem Marx"
+ },
+ hero_of_our_time: {
+ title: "The Alchemist ",
+ language: "English",
+ author: "PAULO COELHO"
+ },
+ don_quixote: {
+ title: "The Night Bird",
+ language: "English",
+ author: "Brian Freeman"
+ },
+ returning_to_haifa: {
+ title: "From Sand and Ash",
+ language: "English",
+ author: "Amy Harmon"
+ },
+ beirut_nightmares: {
+ title: "Dead Certain",
+ language: "Englsih",
+ author: "Adam Mitzner"
+ },
+ doctor_zhivago: {
+ title: " I Am Watching You",
+ language: "English",
+ author: "Teresa Driscoll"
+ },
+ song_of_ice_and_fire: {
+ title: "The Letter' by Kathryn Hughes",
+ language: "English",
+ author: " Kathryn Hughes"
+ }
+};
+
+function generateBooksList() {
+ let myBooksInfo = document.createElement("ul");
+ document.body.appendChild(myBooksInfo);
+
+ for (let booksId in myBooksInformation) {
+ let li = document.createElement("li");
+ li.setAttribute("id", booksId);
+ myBooksInfo.appendChild(li);
+
+ let b_title = document.createElement("h2");
+ li.appendChild(b_title);
+ b_title.innerHTML = myBooksInformation[booksId].title;
+
+ let b_language = document.createElement("p");
+ li.appendChild(b_language);
+ b_language.innerHTML = myBooksInformation[booksId].language;
+
+ let b_author = document.createElement("h4");
+ li.appendChild(b_author);
+ b_author.innerHTML = "by : < " + myBooksInformation[booksId].author + " >";
+ };
+}
+
+generateBooksList();
+
+let MyBookCovers = {
+ harry_potter_and_the_deathly_hallows: "https://media.bloomsbury.com/rep/bj/9780747591061.jpg",
+ The_Baloch_and_Balochistan: "https://images-na.ssl-images-amazon.com/images/I/51O3nqWcmqL._SX322_BO1,204,203,200_.jpg",
+ The_Baloch_Conflict_with_Iran_and_Pakistan: "https://thewire.in/wp-content/uploads/2017/12/Baloch-conflict.png",
+ Balochistan_At_a_Crossroads_Reviews: "https://images-na.ssl-images-amazon.com/images/I/81n%2B%2B6UluJL.jpg",
+ The_Alchemist: "https://n1.sdlcdn.com/imgs/b/y/q/624303691271_1-ed95c.jpg",
+ The_Night_Bird: "https://images-na.ssl-images-amazon.com/images/I/51HrCVynYBL.jpg",
+ From_Sand_and_Ash: "https://images-na.ssl-images-amazon.com/images/I/51KRuC%2BmItL.jpg",
+ Dead_Certain: "https://images-na.ssl-images-amazon.com/images/I/5132qfIGVwL._SY346_.jpg",
+ I_Am_Watching_You: "https://images-na.ssl-images-amazon.com/images/I/51PeVt0WznL._SY346_.jpg",
+ You_The_Letter_by_Kathryn_Hughes: "https://images-na.ssl-images-amazon.com/images/I/51VE8UMU35L.jpg"
+};
+
+function bookCovers() {
+ for (let j in myBooksInformation) {
+ var img = document.createElement("img");
+ img.setAttribute("src", MyBookCovers[j]);
+ img.setAttribute("alt", j);
+ let bookImg = document.getElementById(j);
+ bookImg.appendChild(img);
+ }
}
+bookCovers();
From dbd0e156633366eb80c7c687513e808ae8ff0201 Mon Sep 17 00:00:00 2001
From: Keyya <43468230+keyyaali@users.noreply.github.com>
Date: Fri, 23 Nov 2018 01:33:06 +0100
Subject: [PATCH 4/4] Update maartjes_work.js
---
Week2/homework/maartjes_work.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Week2/homework/maartjes_work.js b/Week2/homework/maartjes_work.js
index 0b451d122..996955f7c 100644
--- a/Week2/homework/maartjes_work.js
+++ b/Week2/homework/maartjes_work.js
@@ -45,3 +45,31 @@ const tuesday = [
const tasks = monday.concat(tuesday);
// Add your code here
+{ name: 'Write a summary HTML/CSS',
+ duration: 180 },
+ { name: 'Some web development',
+ duration: 120 },
+ { name: 'Fix homework for class10',
+ duration: 20 },
+ { name: 'Talk to a lot of people',
+ duration: 200 }
+ ];
+ const tuesday = [
+ { name: 'Keep writing summary',
+ duration: 240 },
+ { name: 'Some more web development',
+ duration: 180 },
+ { name: 'Staring out the window',
+ duration: 10 },
+ { name: 'Talk to a lot of people',
+ duration: 200 },
+ { name: 'Look at application assignments new students',
+ duration: 40 }
+ ];
+ const tasks = monday.concat(tuesday);
+let twoDaysIncome = tasks
+ .map(task => task.duration / 60)
+ .filter(task => task >= 2)
+ .map(total => total * 60)
+ .reduce((a, b) => a + b, 0);
+ console.log("Maartje earned " +twoDaysIncome+ ".00 Euro on Monday and Tuesday!");
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