diff --git a/Week1/homework/1984.jpg b/Week1/homework/1984.jpg new file mode 100644 index 000000000..136946d0c Binary files /dev/null and b/Week1/homework/1984.jpg differ diff --git a/Week1/homework/The_Crimson_Rivers.jpg b/Week1/homework/The_Crimson_Rivers.jpg new file mode 100644 index 000000000..73685e158 Binary files /dev/null and b/Week1/homework/The_Crimson_Rivers.jpg differ diff --git a/Week1/homework/a tale of two cities.jpg b/Week1/homework/a tale of two cities.jpg new file mode 100644 index 000000000..01bc67f40 Binary files /dev/null and b/Week1/homework/a tale of two cities.jpg differ diff --git a/Week1/homework/a_clash_of_kings.jpg b/Week1/homework/a_clash_of_kings.jpg new file mode 100644 index 000000000..95cb46092 Binary files /dev/null and b/Week1/homework/a_clash_of_kings.jpg differ diff --git a/Week1/homework/app.js b/Week1/homework/app.js deleted file mode 100644 index ffef836dc..000000000 --- a/Week1/homework/app.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; -{ - const bookTitles = [ - // Replace with your own book titles - 'harry_potter_chamber_secrets' - ]; - - - // Replace with your own code - console.log(bookTitles); -} diff --git a/Week1/homework/app1.js b/Week1/homework/app1.js new file mode 100644 index 000000000..2de171083 --- /dev/null +++ b/Week1/homework/app1.js @@ -0,0 +1,13 @@ +const books =[ + "the_crimson_iver", + "hobbit", + "1984", + "the_return_of_the_king", + "the_ruins_of_gorlan ", + "a_clash_of_kings", + "the_forty_rules_of_love", + "my_name_is_red", + "the_new_york_triology", + "the_tale_of_two_cities" +]; +console.log(books) \ No newline at end of file diff --git a/Week1/homework/app4.js b/Week1/homework/app4.js new file mode 100644 index 000000000..df0897d25 --- /dev/null +++ b/Week1/homework/app4.js @@ -0,0 +1,58 @@ +const bookInfo ={ + the_crimson_river : { + title : "The crimson River", + author: "Jean-Christophe Grangé", + language : "Frech" + + }, + hobbit:{ + title : "Hobbit", + author : "J.J.Tolkein", + language : "English" + + }, + 1984:{ + title : "1984", + author : "George Orwel", + language : "English" + + }, + + the_return_of_the_king:{ + title : "The Return of the King", + author : "J.J.Tolkein", + language : "English" + }, + + the_ruins_of_gorlan:{ + title : "The Ruins of Gorlan", + author : "John Flanagan", + language : "English" + }, + a_clash_of_kings:{ + title : "A Clash of Kings", + author : "J. R. Martin", + language : "English" + }, + the_forty_rules_of_love:{ + title : "The Forthy Rules of Love", + author : "Elif Safak", + language : "Turkish" + }, + my_name_is_red:{ + title : "my Name is Red", + author : "Orhan Pamuk", + language : "Turkish" + }, + the_new_york_triology:{ + title : "THe New York Triology", + author :"Paul Auster", + language : "English" + }, + the_tale_of_two_cities:{ + title : "The Tale of Two Cities", + author : "Charles Dickens", + language : "English" + } +} +console.log(bookInfo.my_name_is_red.title); \ No newline at end of file diff --git a/Week1/homework/app5-7.js b/Week1/homework/app5-7.js new file mode 100644 index 000000000..b74c2444f --- /dev/null +++ b/Week1/homework/app5-7.js @@ -0,0 +1,155 @@ +'use strict' +const books =[ + "the_crimson_iver", + "hobbit", + "1984", + "the_return_of_the_king", + "the_ruins_of_gorlan ", + "a_clash_of_kings", + "the_forty_rules_of_love", + "my_name_is_red", + "the_new_york_triology", + "the_tale_of_two_cities" + +]; +const bookInfo ={ + the_crimson_river : { + title : "The crimson River", + author: "Jean-Christophe Grangé", + language : "Frech" + + }, + hobbit:{ + title : "Hobbit", + author : "J.J.Tolkein", + language : "English" + + }, + 1984:{ + title : "1984", + author : "George Orwel", + language : "English" + + }, + + the_return_of_the_king:{ + title : "The Return of the King", + author : "J.J.Tolkein", + language : "English" + }, + + the_ruins_of_gorlan:{ + title : "The Ruins of Gorlan", + author : "John Flanagan", + language : "English" + }, + a_clash_of_kings:{ + title : "A Clash of Kings", + author : "J. R. Martin", + language : "English" + }, + the_forty_rules_of_love:{ + title : "The Forthy Rules of Love", + author : "Elif Safak", + language : "Turkish" + }, + my_name_is_red:{ + title : "my Name is Red", + author : "Orhan Pamuk", + language : "Turkish" + }, + the_new_york_triology:{ + title : "The New York Triology", + author :"Paul Auster", + language : "English" + }, + the_tale_of_two_cities:{ + title : "The Tale of Two Cities", + author : "Charles Dickens", + language : "English" + } +} + +function bookDetails(){ + const ul = document.createElement("ul"); + + for (let i in books){ + + let bookLabel = books[i]; + let li = document.createElement("li") + li.innerHTML=bookLabel; + + + let bookHead = document.createElement("h2"); + bookHead.innerHTML=bookLabel.title; + + + let bookAuthor = document.createElement("p"); + bookAuthor.innerHTML = bookLabel.author + + + let bookLanguage = document.createElement("p") + bookLanguage.innerHTML=bookLabel.language; + + li.appendChild(ul); + bookHead.appendChild(li); + bookAuthor.appendChild(li); + bookLanguage.appendChild(li); + + + } + document.getElementById("show").appendChild(ul); +} +window.addEventListener("load",bookDetails) + + + + + + + +//const ul = document.createElement("ul") +/*function bookList(){ + for (let i=0; i"; + } + makeList += "" + document.getElementById("show").innerHTML=makeList; + //document.getElementById("show").appendChild(makeList) + } + \ No newline at end of file diff --git a/Week1/homework/hobbit.jpg b/Week1/homework/hobbit.jpg new file mode 100644 index 000000000..edf6d705a Binary files /dev/null and b/Week1/homework/hobbit.jpg differ diff --git a/Week1/homework/my_name_is_red.jpg b/Week1/homework/my_name_is_red.jpg new file mode 100644 index 000000000..524d1d0af Binary files /dev/null and b/Week1/homework/my_name_is_red.jpg differ diff --git a/Week1/homework/the return of the king.jpg b/Week1/homework/the return of the king.jpg new file mode 100644 index 000000000..bf49ce2c4 Binary files /dev/null and b/Week1/homework/the return of the king.jpg differ diff --git a/Week1/homework/the_forty_rules_of_love.jpg b/Week1/homework/the_forty_rules_of_love.jpg new file mode 100644 index 000000000..f74cd5879 Binary files /dev/null and b/Week1/homework/the_forty_rules_of_love.jpg differ diff --git a/Week1/homework/the_new_york_triology.jpg b/Week1/homework/the_new_york_triology.jpg new file mode 100644 index 000000000..7d37747dd Binary files /dev/null and b/Week1/homework/the_new_york_triology.jpg differ diff --git a/Week1/homework/the_ruins_of_gorlan.jpg b/Week1/homework/the_ruins_of_gorlan.jpg new file mode 100644 index 000000000..8faf256b4 Binary files /dev/null and b/Week1/homework/the_ruins_of_gorlan.jpg differ diff --git a/Week2/homework/maartjes_work.js b/Week2/homework/maartjes_work.js index 0b451d122..f64d8da03 100644 --- a/Week2/homework/maartjes_work.js +++ b/Week2/homework/maartjes_work.js @@ -45,3 +45,13 @@ const tuesday = [ const tasks = monday.concat(tuesday); // Add your code here +let twoHoursTasks = tasks.filter(x => x.duration >=120); +//console.log(twoHoursTasks); + +let totalWorkingTime = twoHoursTasks.map(x => x.duration); +//console.log(totalWorkingTime); + +const salaryPerHour = 25.5; + +let totalSalary = totalWorkingTime.reduce((acc,val) => (acc + val)/60 * salaryPerHour,0) +console.log( "The salary of Maartje is "+"€ " +totalSalary.toFixed(2)) \ No newline at end of file diff --git a/Week2/homework/map_filter.js b/Week2/homework/map_filter.js index b6af22631..dc8c37bfc 100644 --- a/Week2/homework/map_filter.js +++ b/Week2/homework/map_filter.js @@ -2,4 +2,7 @@ const numbers = [1, 2, 3, 4]; -// Add your code here +let oddNumbers = numbers.filter(x => x % 2 !==0); +console.log(oddNumbers); +let doubleNumbers = oddNumbers.map(x => x*2); +console.log('The doubled numbers are :', doubleNumbers) diff --git a/Week3/homework/1-step3.js b/Week3/homework/1-step3.js index bee3be0a0..8bbd9203a 100644 --- a/Week3/homework/1-step3.js +++ b/Week3/homework/1-step3.js @@ -1,7 +1,7 @@ 'use strict'; function foo(func) { - // What to do here? +return bar(); } function bar() { diff --git a/Week3/homework/2-step3.js b/Week3/homework/2-step3.js index 777ca2038..6c3e9e52a 100644 --- a/Week3/homework/2-step3.js +++ b/Week3/homework/2-step3.js @@ -2,7 +2,29 @@ function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) { const values = []; - // Add your code here + + for (let i =startIndex; i <=stopIndex; i++){ + values.push(i) + } + //console.log(values) + + for(let i = 0; i console.log(x + " can be divided by three") + +let sayFive= (x) => console.log( x + " can be divided by five") + -threeFive(10, 15, sayThree, sayFive); +threeFive(10, 15); diff --git a/Week3/homework/3-step3.js b/Week3/homework/3-step3.js index 75200818b..cd9564b2e 100644 --- a/Week3/homework/3-step3.js +++ b/Week3/homework/3-step3.js @@ -2,16 +2,24 @@ // use a 'for' loop function repeatStringNumTimesWithFor(str, num) { - // add your code here - return str; + // repeat after me + let x = ""; + for (let i=num; i>0; --i){ + x += str + } + return x; } console.log('for', repeatStringNumTimesWithFor('abc', 3)); // use a 'while' loop function repeatStringNumTimesWithWhile(str, num) { - // add your code here - return str; + let x = "" + while(num>0){ + num-- + x += str; + } + return x; } console.log('while', repeatStringNumTimesWithWhile('abc', 3)); @@ -19,7 +27,26 @@ console.log('while', repeatStringNumTimesWithWhile('abc', 3)); // use a 'do...while' loop function repeatStringNumTimesWithDoWhile(str, num) { // add your code here - return str; + let x ="" + do { + x += str; + num-- + } while(num>0) + return x; } console.log('while', repeatStringNumTimesWithDoWhile('abc', 3)); + + +//bonus +let solutionWithFunction = (str,num) => { + if (num < 0) + return str ="" + if (num == 1) + return str + else { + return str + solutionWithFunction(str,num-1) + + } +} +console.log('bonus', solutionWithFunction('abc', 3)); \ No newline at end of file diff --git a/Week3/homework/4-step3.js b/Week3/homework/4-step3.js index 52a0e9d74..fc19712e7 100644 --- a/Week3/homework/4-step3.js +++ b/Week3/homework/4-step3.js @@ -1,2 +1,9 @@ 'use strict'; // paste your freeCodeCamp solutions in here +function Dog(){ + this.name="Pluto"; + this.color="Brown"; + this.numLegs=4 +} + +let hound = new Dog; \ No newline at end of file diff --git a/Week3/homework/5-step3.js b/Week3/homework/5-step3.js index 52a0e9d74..02d4fea94 100644 --- a/Week3/homework/5-step3.js +++ b/Week3/homework/5-step3.js @@ -1,2 +1,24 @@ 'use strict'; // paste your freeCodeCamp solutions in here +function multiplyAll(arr) { + var product = 1; + let dim = [arr.length, arr[0].length]; + // Only change code below this line + for (let i =0; i{ + for(let i in arr){ + Array.isArray(arr[i]) ? getElementOfArray(arr[i]) : console.log(arr[i]); + } + } diff --git a/Week3/homework/7-step3.js b/Week3/homework/7-step3.js index af1712faf..b9716c41c 100644 --- a/Week3/homework/7-step3.js +++ b/Week3/homework/7-step3.js @@ -22,4 +22,5 @@ f2(y); console.log(y); // Add your explanation as a comment here - +//in the f1 function val x is referenced because x is an variable. Thus the actual x would not be changed by the execution of f1 +//because y is an object, the value of it is passed to the function f2 and the execution of f2 causes a change in the value of y. diff --git a/Week3/homework/step4-bonus.js b/Week3/homework/step4-bonus.js index 4e89b29e7..1596da031 100644 --- a/Week3/homework/step4-bonus.js +++ b/Week3/homework/step4-bonus.js @@ -2,9 +2,16 @@ const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c']; +function eliminatingDuplicatedElement(arr){ + return arr.filter (function(value, index, array){ return array.indexOf(value) == index}) +} + const uniqueValues = eliminatingDuplicatedElement(values) + + // Add your function here. Try and come up with a good name for this function // Replace `yourFunction` with the name of the function you just created -const uniqueValues = yourFunction(values); + console.log(uniqueValues); + diff --git a/Week3/homework/step4.js b/Week3/homework/step4.js index e38d43447..650ef6bcd 100644 --- a/Week3/homework/step4.js +++ b/Week3/homework/step4.js @@ -1,8 +1,14 @@ 'use strict'; // Add your code here +function createBase(parOuter){ + let inner = (parInner) => console.log(parOuter+parInner); + + return inner; +} const addSix = createBase(6); addSix(10); // returns 16 addSix(21); // returns 27 +//addSix(45)