diff --git a/Week1/homework/app.js b/Week1/homework/app.js index a9b5f75d8..f607f7e80 100644 --- a/Week1/homework/app.js +++ b/Week1/homework/app.js @@ -1,11 +1,122 @@ -'use strict'; +'use strict'; { - const bookTitles = [ - // Replace with your own book titles - 'harry_potter_chamber_secrets', - ]; - // Replace with your own code - console.log(bookTitles); + const title = [ + + 'harry_potter_chamber_secrets', + + 'alchemist', //Paulo coelho + 'paula', + 'orlando', + 'divine-comedy', + 'the-odyssey', + ]; + + let objBooks = { + + "harry_potter_chamber_secrets" : + { + + title :"harry_potter_chamber_secrets", + + language:"english", + + author:"Joanne K. Rowling", + + }, + + "alchemist": + { + title:"alchemist", + + language:"english", + + author:"paulo-coelho", + + }, + + "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", + + } + + + + } + + + + function listBooks() { + + let i = 0; + + let ul = document.createElement('ul') + + for (i = 0; i < title.length; i++) { + + let li = document.createElement('li'); + + li.textContent = title[i]; + + ul.appendChild(li); + } + } + + document.body.appendChild(ul); + document.body.onload = listBooks; + const objBooksArr = []; + for (const newListBooks in objBooks) { + console.log(newListBooks); + objBooksArr.push(objBooks[newListBooks]) + } + + + +const bookPic = { + + 'harry_potter_chamber_secrets':potter.jpg , + 'alchemist':alchemist, + 'paula' :paula.jpg, + 'orlando':woolf.jpg, + 'divine-comedy':divine.jpg, + 'the-odyssey' :odyssy.jpg, +}; + + diff --git a/Week1/homework/index.html b/Week1/homework/index.html index b22147cd1..f86ac5162 100644 --- a/Week1/homework/index.html +++ b/Week1/homework/index.html @@ -1 +1,18 @@ - \ No newline at end of file + + + + + + + + Codestin Search App + + + + + +
+ + + + diff --git a/Week1/homework/odyssy.jpg b/Week1/homework/odyssy.jpg new file mode 100644 index 000000000..f349be938 Binary files /dev/null and b/Week1/homework/odyssy.jpg differ diff --git a/Week1/homework/paula.jpg b/Week1/homework/paula.jpg new file mode 100644 index 000000000..6cab39571 Binary files /dev/null and b/Week1/homework/paula.jpg differ diff --git a/Week1/homework/potter.jpg b/Week1/homework/potter.jpg new file mode 100644 index 000000000..f98d221ed Binary files /dev/null and b/Week1/homework/potter.jpg differ diff --git a/Week1/homework/woolf.jpg b/Week1/homework/woolf.jpg new file mode 100644 index 000000000..8be454ab3 Binary files /dev/null and b/Week1/homework/woolf.jpg differ diff --git a/Week2/example.html b/Week2/example.html index 374f064c4..0d0d7e4eb 100644 --- a/Week2/example.html +++ b/Week2/example.html @@ -14,7 +14,8 @@

Here is your advice for the day:

-

+ + diff --git a/Week2/homework/map-filter.js b/Week2/homework/map-filter.js index c8e8a88c1..0346ce45e 100644 --- a/Week2/homework/map-filter.js +++ b/Week2/homework/map-filter.js @@ -1,4 +1,4 @@ -'use strict'; +/*'use strict'; function doubleOddNumbers(numbers) { // Replace this comment and the next line with your code @@ -12,4 +12,29 @@ console.log(doubleOddNumbers(myNumbers)); module.exports = { myNumbers, doubleOddNumbers, +}; */ + +'use strict'; + +function doubleOddNumbers(numbers) { + + numbers = numbers.filter(num => num % 2 === 1).map(num => num * 2); + + console.log(numbers); + + return numbers; + + + +const myNumbers = [1, 2, 3, 4]; + +console.log(doubleOddNumbers(myNumbers)); +module.exports = { + + myNumbers, + + doubleOddNumbers, + }; + +//finished \ No newline at end of file diff --git a/Week2/homework/week2maartjes-work.js b/Week2/homework/week2maartjes-work.js new file mode 100644 index 000000000..4fa673ab9 --- /dev/null +++ b/Week2/homework/week2maartjes-work.js @@ -0,0 +1,133 @@ + +'use strict'; + + + +const monday = [ + + { + + 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 maartjesTasks = monday.concat(tuesday); + +const maartjesHourlyRate = 20; + + + +function computeEarnings(tasks, hourlyRate) { + + const inHoursArr = tasks.map(task => task.duration / 60).filter(hours => hours <= 2); + + const maartjesPayArr = inHoursArr.map(hours => hours * maartjesHourlyRate); + + const totalPay = maartjesPayArr.reduce((sum, amount) => sum + amount); + + const toEuro = totalPay.toFixed(2); + + return toEuro; + +} + + + + + +const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); + + + +//converting + + + +console.log(`Martje has earned €${earnings}`); + + +module.exports = { + + maartjesTasks, + + maartjesHourlyRate, + + computeEarnings, + +}; \ No newline at end of file diff --git a/Week2/lecture-exercises.js b/Week2/lecture-exercises.js index 1fdfef4e0..68d136493 100644 --- a/Week2/lecture-exercises.js +++ b/Week2/lecture-exercises.js @@ -9,9 +9,41 @@ async function getRandomAdvice() { return adviceData.slip.advice; } +let allAdvice=[] +const adviceEl = document.getElementById('advice'); + + +function updateDOM() { + adviceEl.innerHTML= ''; + + allAdvice.forEach((advice, index)=> { + + + const adviceItem=document.createElement ('li') + adviceEl.appendChild(adviceItem); + adviceItem.innerText=advice; + + const removeButton =document.createElement('button') + removeButton.innerText='remove'; + adviceItem.appendChild(removeButton); + removeButton.addEventListener('click',() => deleteAdvice(index));_ +}) + } + function deleteAdvice (index){ + allAdvice.splice(index,1); + updateDOM(); + } + function upcaseAllAdvice (){ + allAdvice=allAdvice.map(advice => advice.toUpperCase()); + updateDOM(); + async function setRandomAdvice() { - const adviceEl = document.getElementById('advice'); - adviceEl.innerText = await getRandomAdvice(); + allAdvice.push (await getRandomAdvice()); + updateDOM(); } setRandomAdvice(); + +document.getElementById('add-advice').addEventListener('click', setRandomAdvice); + +document.getElementById('upcase-everything').addEventListener('click', upcaseAllAdvice); \ No newline at end of file