diff --git a/js2w1hw/Awaken_the_Giant_Within.jpg b/js2w1hw/Awaken_the_Giant_Within.jpg new file mode 100644 index 000000000..b32ff0eaa Binary files /dev/null and b/js2w1hw/Awaken_the_Giant_Within.jpg differ diff --git a/js2w1hw/a_tale_of_two_cities.jpg b/js2w1hw/a_tale_of_two_cities.jpg new file mode 100644 index 000000000..5107d9391 Binary files /dev/null and b/js2w1hw/a_tale_of_two_cities.jpg differ diff --git a/js2w1hw/app.js b/js2w1hw/app.js new file mode 100644 index 000000000..eada8ed00 --- /dev/null +++ b/js2w1hw/app.js @@ -0,0 +1,132 @@ +//1.1 +('use strict'); + +const booksIds = [ + 'a_tale_of_two_cities.', + 'awaken_the_giant_within.', + 'david_copperfield.', + 'nlp.', + 'notes_from_a_friend.', + 'stress_free_life.', + 'arabian_nights.', + 'the_secret.', + 'unlimited_power.', + 'the_power_of_self_mastery.', +]; +console.log(booksIds); + +//1.3 + +// listBooks = booksIds => { +// const body = document.querySelector('body'); +// const h2 = document.createElement('h2'); +// h2.textContent = 'JS2 - Week1 - H.W'; +// body.appendChild(h2); +// const ul = document.createElement('ul'); +// document.body.appendChild(ul); +// ul.id = 'booksIds'; + +// for (let i = 0; i < booksIds.length; i++) { +// let li = document.createElement('li'); +// li.textContent = booksIds[i]; +// ul.appendChild(li); +// } +// }; +// listBooks(booksIds); + +//1.4 +const booksDetails = { + a_tale_of_two_cities: { + title: 'a_tale_of_two_cities', + language: 'English', + author: 'charles_dickens', + }, + awaken_the_giant_within: { + title: 'awaken_the_giant_within', + language: 'English', + author: 'Anthony Robbins', + }, + david_copperfield: { + title: 'david_copperfield', + language: 'English', + author: 'charles_dickens', + }, + nlp: { + title: 'nlp', + language: 'Arabic', + author: 'Ibrahim el_fiky', + }, + notes_from_a_friend: { + title: 'notes_from_a_friend', + language: 'English', + author: 'Anthony Robbins', + }, + stress_free_life: { + title: 'stress_free_life', + language: 'Arabic', + author: 'Ibrahim el_fiky', + }, + Arabian_Nights: { + title: 'Arabian_Nights', + language: 'Arabic', + author: 'unknown', + }, + the_secret: { + title: 'the_secret', + language: 'English', + author: 'Rhonda_Byrne', + }, + unlimited_power: { + title: 'unlimited_power', + language: 'English', + author: 'Anthony Robbins', + }, + the_power_of_self_mastery: { + title: 'the_power_of_self_mastery', + language: 'Arabic', + author: 'Ibrahim el_fiky', + }, +}; +console.log(booksDetails); + +//1.3 +listBooks = booksIds => { + for (let i = 0; i < booksIds.length; i++) { + const body = document.querySelector('body'); + body.innerHTML = ''; + document.querySelector('ul')[0].setAttribute('id', 'booksIds'); + document.querySelector('#booksIds').appendChild(li); + ('
  • booksIds[i]
  • '); + } +}; +listBooks(booksIds); + +// listDetails = booksDetails => { +// document.body.innerHTML = ''; +// //document.appendChild('body'); +// let li = '
  • booksDetails[i]
  • '; + +// for (let i = 0; i < booksDetails.length; i++) { +// document.ul.innerHTML = '
  • booksDetails[i]
  • '; +// document.ul.appendChild('li'); +// } +// }; + +//listDetails(booksDetails); + +//1.7 +// const booksCovers = { +// a_tale_of_two_cities: 'file:///Users/riamalali/Desktop/js2w1hw/a_tale_of_two_cities.jpg', +// awaken_the_giant_within: 'file:///Users/riamalali/Desktop/js2w1hw/Awaken_the_Giant_Within.jpg', +// david_copperfield: 'file:///Users/riamalali/Desktop/js2w1hw/david_copperfield.jpg', +// nlp: 'file:///Users/riamalali/Desktop/js2w1hw/neuro-linguistic-programming.jpg', +// notes_from_a_friend: 'file:///Users/riamalali/Desktop/js2w1hw/notesfromafriend.jpg', +// stress_free_life: 'file:///Users/riamalali/Desktop/js2w1hw/stress_free_life.jpg', +// arabian_nights: 'file:///Users/riamalali/Desktop/js2w1hw/the_arabian_nights.jpg', +// the_secret: 'file:///Users/riamalali/Desktop/js2w1hw/the_secret.jpg', +// unlimited_power: 'file:///Users/riamalali/Desktop/js2w1hw/unlimited_power.jpg', +// the_power_of_self_mastery: +// 'file:///Users/riamalali/Desktop/js2w1hw/the_power_of_self_mastery.jpg', +// }; + +//8 diff --git a/js2w1hw/david_copperfield.jpg b/js2w1hw/david_copperfield.jpg new file mode 100644 index 000000000..e864e5a84 Binary files /dev/null and b/js2w1hw/david_copperfield.jpg differ diff --git a/js2w1hw/js2w1hw.html b/js2w1hw/js2w1hw.html new file mode 100644 index 000000000..5c1ec7d83 --- /dev/null +++ b/js2w1hw/js2w1hw.html @@ -0,0 +1,24 @@ + + + + + + + Codestin Search App + + + + + + diff --git a/js2w1hw/nlp.jpg b/js2w1hw/nlp.jpg new file mode 100644 index 000000000..71c10ca9a Binary files /dev/null and b/js2w1hw/nlp.jpg differ diff --git a/js2w1hw/notes_from_a_friend.jpg b/js2w1hw/notes_from_a_friend.jpg new file mode 100644 index 000000000..b05d08910 Binary files /dev/null and b/js2w1hw/notes_from_a_friend.jpg differ diff --git a/js2w1hw/stress_free_life.jpg b/js2w1hw/stress_free_life.jpg new file mode 100644 index 000000000..1a5b6a0c6 Binary files /dev/null and b/js2w1hw/stress_free_life.jpg differ diff --git a/js2w1hw/the_arabian_nights.jpg b/js2w1hw/the_arabian_nights.jpg new file mode 100644 index 000000000..318e1dcb7 Binary files /dev/null and b/js2w1hw/the_arabian_nights.jpg differ diff --git a/js2w1hw/the_power_of_self_mastery.jpg b/js2w1hw/the_power_of_self_mastery.jpg new file mode 100644 index 000000000..b0abbdb28 Binary files /dev/null and b/js2w1hw/the_power_of_self_mastery.jpg differ diff --git a/js2w1hw/the_secret.jpg b/js2w1hw/the_secret.jpg new file mode 100644 index 000000000..90cfa8586 Binary files /dev/null and b/js2w1hw/the_secret.jpg differ diff --git a/js2w1hw/unlimited_power.jpg b/js2w1hw/unlimited_power.jpg new file mode 100644 index 000000000..df79660fe Binary files /dev/null and b/js2w1hw/unlimited_power.jpg differ diff --git a/js2w2hw/index.html b/js2w2hw/index.html new file mode 100644 index 000000000..0680e02c5 --- /dev/null +++ b/js2w2hw/index.html @@ -0,0 +1,12 @@ + + + + + + + Codestin Search App + + + + + diff --git a/js2w2hw/js2w2hw.js b/js2w2hw/js2w2hw.js new file mode 100644 index 000000000..8a4fa4285 --- /dev/null +++ b/js2w2hw/js2w2hw.js @@ -0,0 +1,26 @@ +'use strict'; + +//1.1 + +function doubleOddNumbers(numbers) { + const newNumbers = numbers.filter(number => number % 2 !== 0).map(number => number * 2); + return newNumbers; +} +const myNumbers = [1, 2, 3, 4]; +console.log(doubleOddNumbers(myNumbers)); + +//2 +const maartjesTask = monday.concat(tuesday); +const maartjesHourlyRate = 20; + +function computeEarnings(tasks, hourlyRate) { + return tasks + .map(task => task.duration / 60) + .filter(hours => hours >= 2) + .map(hours => hours * hourlyRate) + .reduce((total, amount) => total + amount, 0); +} + +const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); +console.log(`Maartjes has earned ${earnings.toFixed(2)} Euro`); +// couldn't solve it this way untill Mr.Jim did it