-
Notifications
You must be signed in to change notification settings - Fork 33
Week3 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Week3 #24
Changes from 8 commits
b805713
b757fdd
4c4690d
5263def
40e4ccb
e45c2c1
9ec3cd4
58d7c4a
8a2a4bb
9376435
963fdde
5723d20
bb1baa6
5e575a9
19699c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,122 @@ | ||
| 'use strict'; | ||
|
|
||
| 'use strict'; | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This opening bracket will cause problems... |
||
| 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); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this actually adding elements to the screen. Do you see anything on yours? You have to then add the |
||
| } | ||
|
|
||
| document.body.appendChild(ul); | ||
| document.body.onload = listBooks; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, Think you'll have to do Prettier for everything. See how the indentation is off here? |
||
| 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, | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,18 @@ | ||
| <!-- replace this with your HTML content --> | ||
| <!-- replace this with your HTML content --> | ||
| <!DOCTYPE html> | ||
|
|
||
| <html> | ||
|
|
||
| <head> | ||
|
|
||
| <title> Book Titles</title> | ||
| <script src="app.js"></script> | ||
|
|
||
| </head> | ||
| <body> | ||
|
|
||
| <div id="objBooksArr"></div> | ||
|
|
||
|
|
||
| </body> | ||
| </html> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange spacing here too |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice job! But there seems to be many blank lines above and below. Can you delete? |
||
|
|
||
| console.log(numbers); | ||
|
|
||
| return numbers; | ||
|
|
||
|
|
||
|
|
||
| const myNumbers = [1, 2, 3, 4]; | ||
|
|
||
| console.log(doubleOddNumbers(myNumbers)); | ||
| module.exports = { | ||
|
|
||
| myNumbers, | ||
|
|
||
| doubleOddNumbers, | ||
|
|
||
| }; | ||
|
|
||
| //finished | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange spacing in this file too. Too many blank lines. Needs Prettier formatting. |
||
| '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, | ||
|
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,12 @@ | ||
| 'use strict'; | ||
|
|
||
| function foo(func) { | ||
| // What to do here? | ||
| // Replace this comment and the next line with your code | ||
| console.log(func); | ||
| func(); | ||
| } | ||
|
|
||
| function bar() { | ||
|
|
||
| console.log('Hello, I am bar!'); | ||
| } | ||
|
|
||
| foo(bar); | ||
|
|
||
| // Do not change or remove anything below this line | ||
| module.exports = foo; | ||
|
|
||
| //finished |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an extra space here. In fact, I think there looks like to be lots of strange spacing. Can you run prettier on your files so they fix the formatting issues?